home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #2 / Amiga Plus CD - 1999 - No. 2.iso / System-Boost / Workbench / TinyMeter / Source / TinyMeter_prefs / main.c < prev    next >
C/C++ Source or Header  |  1997-02-27  |  97KB  |  3,047 lines

  1. /// headers
  2. /* MUI */
  3. #include <libraries/mui.h>
  4.  
  5. /* System */
  6. #include <dos/dos.h>
  7. #include <graphics/gfxmacros.h>
  8. #include <workbench/workbench.h>
  9. #include <exec/memory.h>
  10. #include <datatypes/pictureclass.h>
  11. #include <libraries/locale.h>
  12.  
  13. /* Prototypes */
  14. #include <clib/alib_protos.h>
  15. #include <clib/exec_protos.h>
  16. #include <clib/dos_protos.h>
  17. #include <clib/icon_protos.h>
  18. #include <clib/graphics_protos.h>
  19. #include <clib/intuition_protos.h>
  20. #include <clib/gadtools_protos.h>
  21. #include <clib/utility_protos.h>
  22. #include <clib/asl_protos.h>
  23.  
  24. #ifndef __GNUC__
  25. #include <clib/muimaster_protos.h>
  26. #else
  27. #include <inline/muimaster.h>
  28. #endif
  29.  
  30. /* ANSI C */
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <stdio.h>
  34.  
  35. #ifndef MAKE_ID
  36. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  37. #endif
  38.  
  39. ///
  40. #define  STRINGARRAY YES
  41. #include "TinyMeterPrefs.lh"
  42. #include "tinymeter.h"
  43.  
  44. static struct MUI_CustomClass *CL_FieldsList;
  45. static struct MUI_CustomClass *CL_ChooseFields;
  46. static struct MUI_CustomClass *CL_MainWindow;
  47. static struct MUI_CustomClass *CL_Composer;
  48. static struct MUI_CustomClass *CL_Launcher;
  49.  
  50. #define USE_ABOUT_COLORS        YES
  51. #define USE_ABOUT_HEADER        YES
  52. #define USE_ABOUT_BODY          YES
  53.  
  54. #define USE_LOGO_COLORS         YES
  55. #define USE_LOGO_HEADER         YES
  56. #define USE_LOGO_BODY           YES
  57.  
  58. #define USE_HEADER_LOGO_COLORS  YES
  59. #define USE_HEADER_LOGO_HEADER  YES
  60. #define USE_HEADER_LOGO_BODY    YES
  61.  
  62. #define USE_QUESTION_COLORS     YES
  63. #define USE_QUESTION_HEADER     YES
  64. #define USE_QUESTION_BODY       YES
  65.  
  66. enum { MEN_PROJECT=1,MEN_ABOUT,MEN_OPEN,MEN_SAVE,MEN_QUIT,CMP_LOAD, CMP_SAVE, CMP_CANCEL, CMP_PROJECT };
  67.  
  68. /*************************************************************************************************/
  69. /* misc funcs                                                                                    */
  70. /*************************************************************************************************/
  71. ///
  72. ULONG DoSuperNew(struct IClass *cl,Object *obj,ULONG tag1,...)
  73. {
  74.     return(DoSuperMethod(cl,obj,OM_NEW,&tag1,NULL));
  75. }
  76.  
  77. LONG xget(Object *obj,ULONG attribute)
  78. {
  79.     LONG x;
  80.     get(obj,attribute,&x);
  81.     return(x);
  82. }
  83.  
  84. initColor(struct GAU_Color *col,Object *obj)
  85. {
  86.     struct MUI_PenSpec pspec;
  87.  
  88.     if(col->pen==TRUE)
  89.     {
  90.     sprintf(&pspec.buf[0],"p%d\0",col->red);
  91.     set(obj,MUIA_Pendisplay_Spec,&pspec);
  92.     }
  93.     else
  94.     {
  95.     sprintf(&pspec.buf[0],"r%08lx,%08lx,%08lx\0",col->red,col->green,col->blue);
  96.     set(obj,MUIA_Pendisplay_Spec,&pspec);
  97.     }
  98. }
  99.  
  100. getColor(struct GAU_Color *col,Object *obj)
  101. {
  102.     struct MUI_PenSpec  *pspec;
  103.     char                *buf;
  104.     ULONG               *dummy1,dummy2,dummy3;
  105.  
  106.  
  107.     get(obj,MUIA_Pendisplay_Spec,&pspec);
  108.     if(buf=(char *)AllocVec(256L,MEMF_CLEAR))
  109.     {
  110.     strcpy(buf,&pspec->buf[0]);
  111.     if(buf[0])
  112.     {
  113.         switch (buf[0])
  114.         {
  115.         case    'r':
  116.             col->pen=(UWORD)FALSE;
  117.             sscanf(buf+1,"%lx,%lx,%lx",&dummy1,&dummy2,&dummy3);
  118.             col->red=(ULONG)dummy1;
  119.             col->green=(ULONG)dummy2;
  120.             col->blue=(ULONG)dummy3;
  121.             break;
  122.         case    'p':
  123.             col->pen=(UWORD)TRUE;
  124.             sscanf(buf+1,"%ld",&col->red);
  125.             break;
  126.         case    'm':
  127.             MUI_RequestA(NULL,NULL,0,"TinyMeterPrefs","BAD LUCK!","Please do not use MUI colors.\nThey are not supported by TinyMeter!\n\nUse Colormap or a RBG color instead.",NULL);
  128.             break;
  129.         }
  130.     }
  131.     FreeVec(buf);
  132.     }
  133. }
  134.  
  135. __saveds __asm void IntuiMsgFunc(__a1 struct IntuiMessage *imsg,__a2 struct FileRequester *req)
  136. {
  137.     if (imsg->Class==IDCMP_REFRESHWINDOW)
  138.         DoMethod(req->fr_UserData,MUIM_Application_CheckRefresh);
  139. }
  140.  
  141. char *getfilename(Object *win,char *title,char *pattern,BOOL save)
  142. {
  143.     static char buf[512];
  144.     struct FileRequester *req;
  145.     struct Window *w;
  146.     static LONG left=-1,top=-1,width=-1,height=-1;
  147.     Object *app = (Object *)xget(win,MUIA_ApplicationObject);
  148.     char *res = NULL;
  149.     static const struct Hook IntuiMsgHook = { { 0,0 },(VOID *)IntuiMsgFunc,NULL,NULL };
  150.  
  151.     get(win,MUIA_Window_Window,&w);
  152.     if (left==-1)
  153.     {
  154.         left   = w->LeftEdge+w->BorderLeft+2;
  155.         top    = w->TopEdge+w->BorderTop+2;
  156.         width  = w->Width-w->BorderLeft-w->BorderRight-4;
  157.         height = w->Height-w->BorderTop-w->BorderBottom-4;
  158.     }
  159.  
  160.     if (req=MUI_AllocAslRequestTags(ASL_FileRequest,
  161.         ASLFR_Window, w,
  162.         ASLFR_TitleText, title,
  163.         ASLFR_InitialLeftEdge, left,
  164.         ASLFR_InitialTopEdge , top,
  165.         ASLFR_InitialWidth   , width,
  166.         ASLFR_InitialHeight  , height,
  167.         ASLFR_InitialPattern , pattern,
  168.         ASLFR_DoSaveMode     , save,
  169.         ASLFR_DoPatterns     , TRUE,
  170.         ASLFR_RejectIcons    , TRUE,
  171.         ASLFR_UserData       , app,
  172.         ASLFR_IntuiMsgFunc   , &IntuiMsgHook,
  173.         TAG_DONE))
  174.     {
  175.         set(app,MUIA_Application_Sleep,TRUE);
  176.         if (MUI_AslRequestTags(req,TAG_DONE))
  177.         {
  178.             if (*req->fr_File)
  179.             {
  180.                 res = buf;
  181.                 strcpy(buf,req->fr_Drawer);
  182.                 AddPart(buf,req->fr_File,sizeof(buf));
  183.             }
  184.             left   = req->fr_LeftEdge;
  185.             top    = req->fr_TopEdge;
  186.             width  = req->fr_Width;
  187.             height = req->fr_Height;
  188.         }
  189.         MUI_FreeAslRequest(req);
  190.         set(app,MUIA_Application_Sleep,FALSE);
  191.     }
  192.     return(res);
  193. }
  194.  
  195. ///
  196.  
  197. extern  struct Library  *SysBase,
  198.             *IntuitionBase,
  199.             *UtilityBase,
  200.             *GfxBase,
  201.             *DOSBase,
  202.             *IconBase;
  203.     struct Library  *MUIMasterBase,
  204.             *LocaleBase;
  205.     struct tm_data  *maindata;
  206.     struct Catalog  *Catalog;
  207.  
  208. /*************************************************************************************************/
  209. /* locale stuff                                                                                  */
  210. /*************************************************************************************************/
  211. ///
  212. char *GetStr(int num)
  213. {
  214.     struct AppString *as = (struct AppString *)AppStrings;
  215.     while (as->as_ID != num) as++;
  216.     if (LocaleBase && Catalog) return(GetCatalogStr(Catalog,num,as->as_Str));
  217.     return((char *)as->as_Str);
  218. }
  219.  
  220. VOID LocalizeStringArray(char **array)
  221. {
  222.     char **x;
  223.     for (x=array;*x;x++) *x = GetStr((int)*x);
  224. }
  225.  
  226. VOID LocalizeNewMenu(struct NewMenu *nm)
  227. {
  228.     for (;nm->nm_Type!=NM_END;nm++) if (nm->nm_Label != NM_BARLABEL) nm->nm_Label = GetStr((int)nm->nm_Label);
  229. }
  230.  
  231. VOID InitLocale(VOID)
  232. {
  233.     if (LocaleBase = OpenLibrary("locale.library",38L)) Catalog = (struct Catalog *)OpenCatalog(NULL,"TinyMeterPrefs.catalog",TAG_DONE);
  234. }
  235.  
  236. VOID ExitLocale(VOID)
  237. {
  238.     if (Catalog)    { CloseCatalog(Catalog);    Catalog   =NULL; }
  239.     if (LocaleBase) { CloseLibrary(LocaleBase); LocaleBase=NULL; }
  240. }
  241.  
  242. Object *MakePen()
  243. {
  244.     return(MUI_NewObject(MUIC_Poppen, MUIA_CycleChain, 1, MUIA_Window_Title, GetStr(MO_MakePen), MUIA_Weight, 0, TAG_DONE));
  245. }
  246.  
  247. ///
  248.  
  249. /*************************************************/
  250. /* some pics                                     */
  251. /*************************************************/
  252.  
  253. #include "about.c"
  254. #include "header_logo.c"
  255. #include "question.c"
  256. #include "logo.c"
  257.  
  258. /*************************************************/
  259. /* default settings                              */
  260. /*************************************************/
  261. ///
  262. struct tm_sys_set default_set=
  263. {
  264.     "TM40",
  265.     1,
  266.  
  267.     10,
  268.     10,
  269.     400,
  270.     2,
  271.  
  272.     "Workbench",
  273.  
  274.     "XHelvetica.font",
  275.     11,
  276.  
  277.     bg_file,
  278.     "hd0:prefs/patterns/leather",
  279.     -3,
  280.     FALSE,0x55555555,0x55555555,0x55555555,
  281.  
  282.     5,
  283.     1,
  284.  
  285.     0,
  286.     TRUE,
  287.  
  288.     win_normal,
  289.     0,
  290.     4,
  291.     4,
  292.     8,
  293.     8,
  294.  
  295.     bd_standard,
  296.     FALSE,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
  297.     FALSE,0x0,0x0,0x0,
  298.  
  299.     idle_own
  300. };
  301.  
  302. struct tm_gau_set g4=
  303. {
  304.     typ_volume,
  305.     typ_histmeter,
  306.  
  307.     200,
  308.  
  309.     "Quill.font",
  310.     11,
  311.  
  312.     "ChipMem",
  313.     "HD1: %kd kb,%p%% free",
  314.     "HD1:",
  315.     FALSE,
  316.     ind_right,
  317.     TRUE,
  318.     TRUE,
  319.     TRUE,
  320.     TRUE,
  321.     FALSE,
  322.     FALSE,
  323.     TRUE,
  324.  
  325.     TRUE,2,0,0,
  326.     TRUE,2,0,0,
  327.     FALSE,0,0xFFFFFFFF,0,
  328.     FALSE,0,0,0xFFFFFFFF,
  329.     FALSE,0xFFFFFFFF,0,0,
  330.     TRUE,2,0,0,
  331.     TRUE,1,0,0,
  332.     TRUE,1,0,0,
  333.  
  334.     NULL
  335. };
  336.  
  337. struct tm_gau_set g3=
  338. {
  339.     typ_idle,
  340.     typ_histmeter,
  341.  
  342.     200,
  343.  
  344.     "Quill.font",
  345.     11,
  346.  
  347.     "ChipMem",
  348.     "CPU %p%% free",
  349.     "",
  350.     FALSE,
  351.     ind_right,
  352.     TRUE,
  353.     TRUE,
  354.     TRUE,
  355.     TRUE,
  356.     FALSE,
  357.     FALSE,
  358.     TRUE,
  359.  
  360.     TRUE,2,0,0,
  361.     TRUE,2,0,0,
  362.     FALSE,0,0xFFFFFFFF,0,
  363.     FALSE,0,0,0xFFFFFFFF,
  364.     FALSE,0xFFFFFFFF,0,0,
  365.     TRUE,2,0,0,
  366.     TRUE,1,0,0,
  367.     TRUE,1,0,0,
  368.  
  369.     &g4
  370. };
  371.  
  372.  
  373. struct tm_gau_set g2=
  374. {
  375.     typ_fast,
  376.     typ_gauge,
  377.  
  378.     20,
  379.  
  380.     "XHelvetica.font",
  381.     11,
  382.  
  383.     "FastMem",
  384.     "%td Bytes free",
  385.     "",
  386.     FALSE,
  387.     ind_right,
  388.     TRUE,
  389.     TRUE,
  390.     TRUE,
  391.     TRUE,
  392.     FALSE,
  393.     FALSE,
  394.     FALSE,
  395.  
  396.     TRUE,2,0,0,
  397.     TRUE,2,0,0,
  398.     FALSE,0,0xFFFFFFFF,0,
  399.     FALSE,0,0,0xFFFFFFFF,
  400.     FALSE,0xFFFFFFFF,0,0,
  401.     TRUE,2,0,0,
  402.     TRUE,1,0,0,
  403.     TRUE,0,0,0,
  404.  
  405.     &g3,
  406. };
  407.  
  408.  
  409. struct tm_gau_set g1=
  410. {
  411.     typ_chip,
  412.     typ_gauge,
  413.  
  414.     20,
  415.  
  416.     "XHelvetica.font",
  417.     11,
  418.  
  419.     "ChipMem",
  420.     "%td Bytes free",
  421.     "",
  422.     FALSE,
  423.     ind_right,
  424.     TRUE,
  425.     TRUE,
  426.     TRUE,
  427.     TRUE,
  428.     FALSE,
  429.     FALSE,
  430.     FALSE,
  431.  
  432.     TRUE,2,0,0,
  433.     TRUE,2,0,0,
  434.     FALSE,0,0xFFFFFFFF,0,
  435.     FALSE,0,0,0xFFFFFFFF,
  436.     FALSE,0xFFFFFFFF,0,0,
  437.     TRUE,2,0,0,
  438.     TRUE,1,0,0,
  439.     TRUE,0,0,0,
  440.  
  441.     &g2
  442. };
  443.  
  444. struct tm_gau_set  default_gauge=
  445. {
  446.     NULL,
  447.     typ_gauge,
  448.  
  449.     80,
  450.  
  451.     "topaz.font",
  452.     8,
  453.  
  454.     "",
  455.     "",
  456.     "",
  457.     FALSE,
  458.     ind_right,
  459.     TRUE,
  460.     TRUE,
  461.     TRUE,
  462.     TRUE,
  463.     FALSE,
  464.     FALSE,
  465.     TRUE,
  466.  
  467.     TRUE,2,0,0,
  468.     TRUE,2,0,0,
  469.     FALSE,0,0xFFFFFFFF,0,
  470.     FALSE,0,0,0xFFFFFFFF,
  471.     FALSE,0xFFFFFFFF,0,0,
  472.     TRUE,2,0,0,
  473.     TRUE,1,0,0,
  474.     TRUE,0,0,0,
  475.  
  476.     NULL
  477. };
  478.  
  479. struct tm_gau_set  default_launcher=
  480. {
  481.     NULL,
  482.     typ_gauge,
  483.  
  484.     80,
  485.  
  486.     "topaz.font",
  487.     8,
  488.  
  489.     "",
  490.     "",
  491.     "",
  492.     FALSE,
  493.     ind_right,
  494.     TRUE,
  495.     TRUE,
  496.     TRUE,
  497.     TRUE,
  498.     FALSE,
  499.     FALSE,
  500.     TRUE,
  501.  
  502.     TRUE,1,0,0,
  503.     TRUE,1,0,0,
  504.     FALSE,0,0xFFFFFFFF,0,
  505.     TRUE,1,0,0,
  506.     TRUE,3,0,0,
  507.     TRUE,2,0,0,
  508.     TRUE,1,0,0,
  509.     TRUE,0,0,0,
  510.  
  511.     NULL
  512. };
  513.  
  514. ///
  515. /*************************************************/
  516. /* Drag & Drop lists                             */
  517. /*************************************************/
  518.  
  519. /******************************************/
  520. /* some hooks                             */
  521. /******************************************/
  522. ///
  523. char *gau_types[]=
  524. {
  525.     (STRPTR)MDL_typ_space,
  526.     (STRPTR)MDL_typ_total,
  527.     (STRPTR)MDL_typ_chip,
  528.     (STRPTR)MDL_typ_fast,
  529.     (STRPTR)MDL_typ_volume,
  530.     (STRPTR)MDL_typ_cpu,
  531.     (STRPTR)MDL_typ_retina,
  532.     (STRPTR)MDL_typ_largest_chip,
  533.     (STRPTR)MDL_typ_largest_fast,
  534.     (STRPTR)MDL_typ_largest_total,
  535.     (STRPTR)MDL_typ_largest_retina,
  536.     (STRPTR)MDL_typ_clock,
  537.     (STRPTR)MDL_typ_simplelauncher,
  538.     (STRPTR)MDL_typ_iconlauncher,
  539.     0L,
  540. };
  541.  
  542. __geta4 ULONG gau_consfunc(__a1 struct tm_gau_set *src)
  543. {
  544.     return(src);
  545. }
  546.  
  547. __geta4 void gau_desfunc(__a1 struct tm_gau_set *src)
  548. {
  549.     FreeVec(src);
  550. }
  551.  
  552. __geta4 ULONG gau_dispfunc(__a2 char **array,__a1 struct tm_gau_set *src)
  553. {
  554.     if(src->type!=0)
  555.     {
  556.     *array++ = gau_types[src->type];
  557.     if(src->type==typ_volume)
  558.     {
  559.         *array   = &src->expansion[0];
  560.     }
  561.     else *array = "";
  562.     }
  563.     else
  564.     {
  565.     *array++ = "-----------------";
  566.     *array   = "";
  567.     }
  568.     return(0L);
  569. }
  570.  
  571. static const struct Hook gau_ConstructHook = { { 0,0 }, (void *)gau_consfunc, NULL, NULL };
  572. static const struct Hook gau_DestructHook  = { { 0,0 }, (void *)gau_desfunc , NULL, NULL };
  573. static const struct Hook gau_DisplayHook   = { { 0,0 }, (void *)gau_dispfunc, NULL, NULL };
  574. ///
  575. /******************************************/
  576. /* FieldsList class                       */
  577. /******************************************/
  578. ///
  579. struct FieldsList_Data
  580. {
  581.     LONG dummy;
  582. };
  583.  
  584.  
  585. ULONG FieldsList_DragQuery(struct IClass *cl,Object *obj,struct MUIP_DragDrop *msg)
  586. {
  587.     if (msg->obj==obj) return(DoSuperMethodA(cl,obj,msg));
  588.     else if (msg->obj==(Object *)muiUserData(obj)) return(MUIV_DragQuery_Accept);
  589.     else return(MUIV_DragQuery_Refuse);
  590. }
  591.  
  592.  
  593. ULONG FieldsList_DragDrop(struct IClass *cl,Object *obj,struct MUIP_DragDrop *msg)
  594. {
  595.     if (msg->obj==obj) return(DoSuperMethodA(cl,obj,msg));
  596.     else
  597.     {
  598.     struct tm_gau_set   *entry;
  599.     LONG                dropmark;
  600.     LONG                sortable;
  601.     LONG                active;
  602.  
  603.     get(obj,MUIA_List_DragSortable,&sortable);
  604.     if (sortable)
  605.     {
  606.         get(msg->obj,MUIA_List_Active,&active);
  607.         if(entry=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),MEMF_CLEAR))
  608.         {
  609.         if((active==typ_simplelauncher)||(active==typ_iconlauncher))
  610.         {
  611.             CopyMem(&default_launcher,entry, sizeof(struct tm_gau_set));
  612.             strcpy(&entry->expansion[0],"Provide a filename!");
  613.         }
  614.         else
  615.         {
  616.             CopyMem(&default_gauge,entry, sizeof(struct tm_gau_set));
  617.         }
  618.         entry->type = (UWORD)active;
  619.         if(active==typ_clock_) entry->gauge_type=typ_clock;
  620.  
  621.         get     (obj,       MUIA_List_DropMark,     &dropmark);
  622.         DoMethod(obj,       MUIM_List_InsertSingle, entry,dropmark);
  623.         set     (obj,       MUIA_List_Active,       dropmark);
  624.         set     (msg->obj,  MUIA_List_Active,       MUIV_List_Active_Off);
  625.         }
  626.     }
  627.     else
  628.     {
  629.         DoMethod(msg->obj,MUIM_List_Remove,MUIV_List_Remove_Active);
  630.     }
  631.     return(obj);
  632.     }
  633. }
  634.  
  635.  
  636. __geta4 ULONG FieldsList_Dispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
  637. {
  638.     switch (msg->MethodID)
  639.     {
  640.     case MUIM_DragQuery: return(FieldsList_DragQuery(cl,obj,(APTR)msg));
  641.     case MUIM_DragDrop : return(FieldsList_DragDrop (cl,obj,(APTR)msg));
  642.     }
  643.     return(DoSuperMethodA(cl,obj,msg));
  644. }
  645. ///
  646. /******************************************/
  647. /* ChooseFields class                     */
  648. /******************************************/
  649. ///
  650. Object *available, *visible;
  651.  
  652. struct ChooseFields_Data
  653. {
  654.     ULONG dummy;
  655. };
  656.  
  657. struct ComposerMsg
  658. {
  659.     ULONG   MethodID;
  660.     Object  *listview;
  661.     struct ChooseFields_Data *data;
  662. };
  663.  
  664. #define Dis_ID_DoubleClickComposer      1
  665. #define Dis_ID_ComposerClose            2
  666. #define Dis_ID_ComposerSave             3
  667. #define Dis_ID_LauncherClose            4
  668. #define Dis_ID_LauncherSave             5
  669. #define Dis_ID_CloneEntry               6
  670.  
  671. #define Originator             ( TAG_USER + 1 )
  672. #define Gauge_Settings         ( TAG_USER + 2 )
  673.  
  674. static ULONG DoubleClickComposer(struct IClass *cl,Object *obj, struct ComposerMsg *msg)
  675. {
  676.     struct tm_gau_set   *desc;
  677.     Object *tmp;
  678.  
  679.     DoMethod(msg->listview,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&desc);
  680.  
  681.     if (desc)
  682.     {
  683.     set((Object *)xget(obj,MUIA_ApplicationObject),MUIA_Application_Sleep,TRUE);
  684.     switch (desc->type)
  685.     {
  686.         case    typ_none:
  687.             break;
  688.         case    typ_iconlauncher:
  689.         case    typ_simplelauncher:
  690.             if (tmp = (APTR)NewObject(CL_Launcher->mcc_Class,NULL,
  691.             Originator, obj,
  692.             Gauge_Settings,      desc,
  693.             TAG_DONE))
  694.             {
  695.             DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_ADDMEMBER,tmp);
  696.             set(tmp,MUIA_Window_Open,TRUE);
  697.             }
  698.             break;
  699.         default:
  700.             if (tmp = (APTR)NewObject(CL_Composer->mcc_Class,NULL,
  701.             Originator, obj,
  702.             Gauge_Settings,      desc,
  703.             TAG_DONE))
  704.             {
  705.             DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_ADDMEMBER,tmp);
  706.             set(tmp,MUIA_Window_Open,TRUE);
  707.             }
  708.             else DisplayBeep(0);
  709.             break;
  710.  
  711.     }
  712.     set((Object *)xget(obj,MUIA_ApplicationObject),MUIA_Application_Sleep,FALSE);
  713.     }
  714.     return((ULONG)0);
  715. }
  716.  
  717. static ULONG Clone_Entry(struct IClass *cl,Object *obj, struct ComposerMsg *msg)
  718. {
  719.     struct tm_gau_set *desc,*news;
  720.     DoMethod(msg->listview,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&desc);
  721.     if (desc)
  722.     {
  723.     if(news=AllocVec(sizeof(struct tm_gau_set),0L))
  724.     {
  725.         CopyMem(desc,news,sizeof(struct tm_gau_set));
  726.         DoMethod(msg->listview,MUIM_List_InsertSingle,news,MUIV_List_Insert_Active);
  727.     }
  728.     }
  729. }
  730.  
  731. static ULONG ChooseFields_New(struct IClass *cl,Object *obj,struct opSet *msg)
  732. {
  733.     Object  *BT_Clone;
  734.     obj = (Object *)DoSuperNew(cl,obj,
  735.     MUIA_Group_Columns, 2,
  736.     MUIA_Group_VertSpacing, 1,
  737.     Child, TextObject, MUIA_Text_Contents, GetStr(MDL_Available), End,
  738.     Child, TextObject, MUIA_Text_Contents, GetStr(MDL_Selected ), End,
  739.     Child, ListviewObject,
  740.         MUIA_Listview_DragType, 1,
  741.         MUIA_Listview_List, available = NewObject(CL_FieldsList->mcc_Class,NULL,
  742.         InputListFrame,
  743.         MUIA_List_SourceArray  , gau_types,
  744.         MUIA_List_ShowDropMarks, FALSE,
  745.         TAG_DONE),
  746.     End,
  747.     Child,VGroup,
  748.         Child, ListviewObject,
  749.         MUIA_Listview_DragType, 1,
  750.         MUIA_Listview_DoubleClick,  TRUE,
  751.         MUIA_Listview_List, visible = NewObject(CL_FieldsList->mcc_Class,NULL,
  752.             InputListFrame,
  753.             MUIA_List_ConstructHook, &gau_ConstructHook,
  754.             MUIA_List_DestructHook , &gau_DestructHook,
  755.             MUIA_List_DisplayHook  , &gau_DisplayHook,
  756.             MUIA_List_Format       , "MIW=50 MAW=100 BAR,",
  757.             MUIA_List_DragSortable , TRUE,
  758.             TAG_DONE),
  759.         End,
  760.         Child, BT_Clone=SimpleButton(GetStr(MCO_Clone)),
  761.     End,
  762.     End;
  763.  
  764.     if (obj)
  765.     {
  766.     DoMethod(visible, MUIM_Notify,MUIA_Listview_DoubleClick,TRUE,obj,2,Dis_ID_DoubleClickComposer,visible);
  767.     DoMethod(BT_Clone,MUIM_Notify,MUIA_Pressed,TRUE,             obj,2,Dis_ID_CloneEntry         ,visible);
  768.  
  769.     set(available,MUIA_UserData,visible);
  770.     set(visible,MUIA_UserData,available);
  771.  
  772.     set(available,MUIA_ShortHelp,GetStr(MDH_Available));
  773.     set(visible,MUIA_ShortHelp,GetStr(MDH_Selected));
  774.     }
  775.  
  776.     return((ULONG)obj);
  777. }
  778.  
  779. ULONG Composer_Close(struct IClass *cl, Object *obj, struct ComposerFinishMsg *msg);
  780. ULONG Launcher_Close(struct IClass *cl, Object *obj, struct LauncherFinishMsg *msg);
  781.  
  782. static __saveds __asm ULONG ChooseFields_Dispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
  783. {
  784.     switch (msg->MethodID)
  785.     {
  786.     case OM_NEW                     : return(ChooseFields_New       (cl,obj,(APTR)msg));
  787.     case Dis_ID_DoubleClickComposer : return(DoubleClickComposer    (cl,obj,(APTR)msg));
  788.     case Dis_ID_ComposerClose       : return(Composer_Close         (cl,obj,(APTR)msg));
  789.     case Dis_ID_LauncherClose       : return(Launcher_Close         (cl,obj,(APTR)msg));
  790.     case Dis_ID_CloneEntry          : return(Clone_Entry            (cl,obj,(APTR)msg));
  791.     }
  792.     return(DoSuperMethodA(cl,obj,msg));
  793. }
  794. ///
  795. /*************************************************/
  796. /* Composer Class                                */
  797. /*************************************************/
  798.  
  799. /******************************************/
  800. /* Composer Menu                          */
  801. /******************************************/
  802. ///
  803.  
  804. struct NewMenu CmpMenuData[] =
  805. {
  806.     { NM_TITLE, (STRPTR)MCM_Gauge          , 0 ,0 ,0             ,(APTR)CMP_PROJECT  },
  807.     { NM_ITEM , (STRPTR)MCM_Open           ,"O",0 ,0             ,(APTR)CMP_LOAD     },
  808.     { NM_ITEM , (STRPTR)MCM_SaveAs         ,"S",0 ,0             ,(APTR)CMP_SAVE     },
  809.     { NM_ITEM ,  NM_BARLABEL               , 0 ,0 ,0             ,(APTR)0            },
  810.     { NM_ITEM , (STRPTR)MCM_Cancel         ,"C",0 ,0             ,(APTR)CMP_CANCEL   },
  811.     { NM_END,NULL,0,0,0,(APTR)0 }
  812. };
  813. ///
  814. /******************************************/
  815. /* Composer class                         */
  816. /******************************************/
  817. ///
  818.  
  819. #define Dis_ID_DoubleClickDevice    8
  820. #define Dis_ID_SaveGauge            9
  821. #define Dis_ID_LoadGauge            10
  822. #define Dis_ID_ShowFormatHelp       11
  823.  
  824. struct Composer_Data
  825. {
  826.     Object              *ST_Label,
  827.             *PO_Device,
  828.             *ST_Device,
  829.             *CY_Type,
  830.             *NB_Height,
  831.             *CS_Colors[16],
  832.             *ST_Font,
  833.             *ST_Format,
  834.             *CM_3D,
  835.             *CM_Border,
  836.             *CM_Bg,
  837.             *CM_Shadow,
  838.             *CM_NoGauge,
  839.             *CM_NoFmt,
  840.             *CM_NoBase,
  841.             *CY_Indent,
  842.             *LV_Device,
  843.             *VL_Device,
  844.             *originator,
  845.             *sub_win,
  846.             *BT_Use,
  847.             *BT_Cancel,
  848.             *PO_Device,
  849.             *CMP_Menu,
  850.             *BT_Quest;
  851.     struct tm_gau_set   *gauge;
  852. };
  853.  
  854. static ULONG DoubleClickDev(struct IClass *cl,Object *obj, struct DoubleClkMsg *msg)
  855. {
  856.     char   *my_ptr;
  857.     struct Composer_Data    *data = INST_DATA(cl,obj);
  858.  
  859.     DoMethod(data->VL_Device,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&my_ptr);
  860.     if(my_ptr)
  861.     {
  862.     set(data->ST_Device,MUIA_String_Contents,my_ptr);
  863.     DoMethod(data->PO_Device,MUIM_Popstring_Close,0L);
  864.     return(DoSuperMethodA(cl,obj,msg));
  865.     }
  866.     else return(0L);
  867. }
  868.  
  869. struct ComposerFinishMsg
  870. {
  871.     ULONG   MethodID;
  872.     Object  *win;
  873.     ULONG   ok;
  874. };
  875.  
  876. ULONG Composer_Close(struct IClass *cl, Object *obj, struct ComposerFinishMsg *msg)
  877. {
  878.     if(msg->ok)
  879.     {
  880.     DoMethod(msg->win,Dis_ID_ComposerSave,msg->win,TRUE);
  881.     }
  882.     set(msg->win,MUIA_Window_Open,FALSE);
  883.     DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_REMMEMBER,msg->win);
  884.  
  885.     MUI_DisposeObject(msg->win);
  886.  
  887.     return((ULONG)0L);
  888. }
  889.  
  890. ULONG Composer_Save(struct IClass *cl, Object *obj, struct ComposerFinishMsg *msg)
  891. {
  892.     int     i;
  893.     ULONG   dummy;
  894.     struct  Composer_Data    *data   = INST_DATA(cl,obj);
  895.     for(i=0;i<8;i++) getColor(&data->gauge->Colors[i],data->CS_Colors[i]);
  896.     get(data->ST_Label  ,MUIA_String_Contents,&dummy); strcpy(&data->gauge->label[0]    , dummy ? (char *)dummy : " " );
  897.     get(data->ST_Device ,MUIA_String_Contents,&dummy); strcpy(&data->gauge->expansion[0], dummy ? (char *)dummy : " " );
  898.     get(data->CY_Type   ,MUIA_Cycle_Active   ,&dummy); data->gauge->gauge_type  =(UWORD)dummy;
  899.     get(data->NB_Height ,MUIA_Numeric_Value  ,&dummy); data->gauge->size_y      =(UWORD)dummy-100;
  900.     get(data->CM_3D     ,MUIA_Selected       ,&dummy); data->gauge->sty_3d      =(UWORD)dummy;
  901.     get(data->CM_Border ,MUIA_Selected       ,&dummy); data->gauge->sty_border  =(UWORD)dummy;
  902.     get(data->CM_Bg     ,MUIA_Selected       ,&dummy); data->gauge->sty_bg      =(UWORD)dummy;
  903.     get(data->CM_Shadow ,MUIA_Selected       ,&dummy); data->gauge->sty_shadow  =(UWORD)dummy;
  904.     get(data->CM_NoGauge,MUIA_Selected       ,&dummy); data->gauge->sty_nogauge =(UWORD)dummy;
  905.     get(data->CM_NoFmt  ,MUIA_Selected       ,&dummy); data->gauge->sty_noformat=(UWORD)dummy;
  906.     get(data->CM_NoBase ,MUIA_Selected       ,&dummy); data->gauge->sty_nobase  =(UWORD)dummy;
  907.     get(data->CY_Indent ,MUIA_Cycle_Active   ,&dummy); data->gauge->indent      =(UWORD)dummy;
  908.     get(data->ST_Font   ,MUIA_String_Contents,&dummy); sscanf((char *)dummy,"%[^/]/%d",&data->gauge->font[0],&i);
  909.     strcat(&data->gauge->font[0],".font"); data->gauge->font_size=(WORD)i;
  910.     get(data->ST_Format ,MUIA_String_Contents,&dummy); strcpy((char *)&data->gauge->format[0], dummy ? (char *)dummy : " " );
  911.     DoMethod(visible,MUIM_List_Redraw,MUIV_List_Redraw_All);
  912. }
  913.  
  914. char   *types[]         ={(STRPTR)MCL_Normal,(STRPTR)MCL_Historymeter,0L};
  915.  
  916. char   *indent[]        ={(STRPTR)MCL_center,(STRPTR)MCL_left,(STRPTR)MCL_right,0L};
  917.  
  918. char   *regcomposer[]   ={(STRPTR)MCR_general,(STRPTR)MCR_flags,(STRPTR)MCR_colors,0L};
  919.  
  920. insertComposerSettings(struct tm_gau_set *gauge, struct Composer_Data *data)
  921. {
  922.     int     i;
  923.     char    dummy[256];
  924.  
  925.     for(i=0;i<8;i++)
  926.     {
  927.     initColor(&gauge->Colors[i],data->CS_Colors[i]);
  928.     if(gauge->type == typ_clock_) set(data->CS_Colors[i],MUIA_Disabled,TRUE);
  929.     }
  930.     set(data->NB_Height,MUIA_Numeric_Value,gauge->size_y+100);
  931.     if(gauge->type != typ_volume) set(data->PO_Device, MUIA_Disabled,TRUE);
  932.     if((gauge->gauge_type==typ_histmeter)||(gauge->type==typ_clock_))
  933.     {
  934.     set(data->ST_Label,  MUIA_Disabled,TRUE);
  935.     set(data->CM_3D,     MUIA_Disabled,TRUE);
  936.     set(data->CM_Shadow, MUIA_Disabled,TRUE);
  937.     if(gauge->type==typ_clock_)
  938.     {
  939.         set(data->CM_Bg,     MUIA_Disabled,TRUE);
  940.         set(data->CS_Colors[col_format] ,MUIA_Disabled,FALSE);
  941.         set(data->CS_Colors[col_dark]   ,MUIA_Disabled,FALSE);
  942.         set(data->CM_Shadow     ,MUIA_Disabled,FALSE);
  943.         set(data->CM_Border     ,MUIA_Disabled,TRUE);
  944.         set(data->CM_NoGauge    ,MUIA_Disabled,TRUE);
  945.         set(data->CM_NoFmt      ,MUIA_Disabled,TRUE);
  946.         set(data->CM_NoBase     ,MUIA_Disabled,TRUE);
  947.         set(data->CY_Type       ,MUIA_Disabled,TRUE);
  948.     }
  949.     }
  950.  
  951.     set(data->CM_3D     ,MUIA_Selected,gauge->sty_3d);
  952.     set(data->CM_Border ,MUIA_Selected,gauge->sty_border);
  953.     set(data->CM_Bg     ,MUIA_Selected,gauge->sty_bg);
  954.     set(data->CM_Shadow ,MUIA_Selected,gauge->sty_shadow);
  955.     set(data->CM_NoGauge,MUIA_Selected,gauge->sty_nogauge);
  956.     set(data->CM_NoFmt  ,MUIA_Selected,gauge->sty_noformat);
  957.     set(data->CM_NoBase ,MUIA_Selected,gauge->sty_nobase);
  958.  
  959.     set(data->ST_Format ,MUIA_String_Contents,&gauge->format[0]);
  960.  
  961.     strcpy(&dummy[0],gauge->font);
  962.     sprintf((char *)&dummy[strlen(&dummy[0])-5],"/%d",gauge->font_size);
  963.  
  964.     set(data->ST_Font   ,MUIA_String_Contents,&dummy[0]);
  965.     set(data->ST_Device ,MUIA_String_Contents,&gauge->expansion[0]);
  966.     set(data->ST_Label  ,MUIA_String_Contents,&gauge->label[0]);
  967.  
  968.     set(data->CY_Indent ,MUIA_Cycle_Active,gauge->indent);
  969.     set(data->CY_Type   ,MUIA_Cycle_Active,gauge->gauge_type);
  970. }
  971.  
  972. LoadGaugeSet(struct IClass *cl,Object *obj)
  973. {
  974.     struct Composer_Data    *data=INST_DATA(cl,obj);
  975.     char                    *file;
  976.     ULONG                   my_file;
  977.     ULONG                   buf;
  978.     UWORD                   old_type;
  979.     char                    old_expansion[128];
  980.  
  981.     if(file=getfilename(obj,GetStr(MCM_LoadGauge),"#?.tmgauge",FALSE))
  982.     {
  983.     if(my_file=(ULONG)Open(file,MODE_OLDFILE))
  984.     {
  985.         Read(my_file,&buf,4L);
  986.         if(buf==0x544D4731)
  987.         {
  988.         old_type=data->gauge->type;
  989.         CopyMem(&data->gauge->expansion[0],&old_expansion[0],128L);
  990.         Read(my_file,data->gauge,sizeof(struct tm_gau_set));
  991.         data->gauge->type=old_type;
  992.         CopyMem(&old_expansion[0],&data->gauge->expansion[0],128L);
  993.         insertComposerSettings(data->gauge,data);
  994.         }
  995.         else MUI_RequestA((Object *)xget(obj,MUIA_ApplicationObject),obj,0,"TinyMeterPrefs",GetStr(MCM_NotTmGauge_fmt),GetStr(MCM_NotTmGauge),NULL);
  996.         Close(my_file);
  997.     }
  998.     }
  999. }
  1000.  
  1001. SaveGaugeSet(struct IClass *cl,Object *obj)
  1002. {
  1003.     struct Composer_Data        *data=INST_DATA(cl,obj);
  1004.     char                        *file;
  1005.     ULONG                       buf,my_file;
  1006.     struct ComposerFinishMsg    msg;
  1007.  
  1008.     msg.ok=TRUE;
  1009.  
  1010.     Composer_Save( cl,obj,&msg);
  1011.  
  1012.     buf=0x544D4731;
  1013.  
  1014.     if(file=getfilename(obj,GetStr(MCM_SaveGauge),"#?.tmgauge",TRUE))
  1015.     {
  1016.     if(my_file=Open(file,MODE_NEWFILE))
  1017.     {
  1018.         Write(my_file,&buf,4L);
  1019.         Write(my_file,data->gauge,sizeof(struct tm_gau_set));
  1020.         Close(my_file);
  1021.     }
  1022.     }
  1023. }
  1024.  
  1025. Object  *WI_HelpFmt,
  1026.     *WI_HelpClock;
  1027.  
  1028. static ULONG Composer_New(struct IClass *cl,Object *obj,struct opSet *msg)
  1029. {
  1030.     struct Composer_Data    *data,*new_data;
  1031.  
  1032.     if(new_data=AllocVec(sizeof(struct Composer_Data),0L))
  1033.     {
  1034.     if(new_data->gauge = (struct tm_gau_set *)GetTagData(Gauge_Settings,0,msg->ops_AttrList))
  1035.     {
  1036.         if( obj = (Object *)DoSuperNew(cl,obj,
  1037.             MUIA_Window_Title       , gau_types[new_data->gauge->type] ,
  1038.             MUIA_Window_ID          , MAKE_ID('T','M','C','O'),
  1039.             MUIA_Window_Menustrip   , new_data->CMP_Menu = MUI_MakeObject(MUIO_MenustripNM,CmpMenuData,0),
  1040.             WindowContents, VGroup, ButtonFrame,
  1041.  
  1042.             Child, HGroup,
  1043.                 Child, VGroup, MUIA_Background, MUII_SHADOW,
  1044.                 Child, VSpace(0),
  1045.                 Child, BodychunkObject,
  1046.                     MUIA_FixWidth             , HEADER_LOGO_WIDTH ,
  1047.                     MUIA_FixHeight            , HEADER_LOGO_HEIGHT,
  1048.                     MUIA_Bitmap_Width         , HEADER_LOGO_WIDTH ,
  1049.                     MUIA_Bitmap_Height        , HEADER_LOGO_HEIGHT,
  1050.                     MUIA_Bodychunk_Depth      , HEADER_LOGO_DEPTH ,
  1051.                     MUIA_Bodychunk_Body       , (UBYTE *)header_logo_body,
  1052.                     MUIA_Bodychunk_Compression, HEADER_LOGO_COMPRESSION,
  1053.                     MUIA_Bodychunk_Masking    , HEADER_LOGO_MASKING,
  1054.                     MUIA_Bitmap_SourceColors  , (ULONG *)header_logo_colors,
  1055.                     MUIA_Bitmap_Transparent   , 0,
  1056.                 End,
  1057.                 End,
  1058.  
  1059.                 Child, RegisterGroup(regcomposer),
  1060.                 MUIA_Register_Frame, TRUE,
  1061.  
  1062.                 Child, ColGroup(2),
  1063.                     Child, VSpace(0),
  1064.                     Child, VSpace(0),
  1065.                     Child, Label(GetStr(MCO_type)),
  1066.                     Child,  new_data->CY_Type=CycleObject,
  1067.                     MUIA_Cycle_Entries, types,
  1068.                     End,
  1069.                     Child, Label(GetStr(MCO_label)),
  1070.                     Child, new_data->ST_Label=String(0L,16),
  1071.                     Child, Label(GetStr(MCO_height)),
  1072.                     Child, ColGroup(2), Child, new_data->NB_Height=MUI_MakeObject(MUIO_NumericButton,NULL,100,1000,GetStr(MCO_height_fmt)), Child, HVSpace, End,
  1073.                     Child, Label(GetStr(MCO_font)),
  1074.                     Child,  PopaslObject,
  1075.                     MUIA_Popstring_String, new_data->ST_Font=(Object *)String(0L,80),
  1076.                     MUIA_Popstring_Button, PopButton(MUII_PopUp),
  1077.                     MUIA_Popasl_Type , ASL_FontRequest,
  1078.                     ASLFO_TitleText  , GetStr(MCO_sel_font),
  1079.                     End,
  1080.                     Child, Label(GetStr(MCO_device)),
  1081.                     Child, new_data->PO_Device=PopobjectObject,
  1082.                     MUIA_Popstring_String, new_data->ST_Device=String(0L,128),
  1083.                     MUIA_Popstring_Button, PopButton(MUII_PopUp),
  1084.                     MUIA_Popobject_Object, new_data->LV_Device=ListviewObject,
  1085.                         MUIA_Weight, 20,
  1086.                         MUIA_Listview_Input, TRUE,
  1087.                         MUIA_Listview_DoubleClick, TRUE,
  1088.                         MUIA_Listview_List, new_data->VL_Device=VolumelistObject,
  1089.                         InputListFrame,
  1090.                         MUIA_Dirlist_Directory, "ram:",
  1091.                         End,
  1092.                     End,
  1093.                     End,
  1094.                     Child, VSpace(0),
  1095.                     Child, VSpace(0),
  1096.                 End,
  1097.                 Child, ColGroup(2),
  1098.                     Child, VSpace(0),
  1099.                     Child, VSpace(0),
  1100.                     Child, Label(GetStr(MCO_3dlook)),
  1101.                     Child, new_data->CM_3D=CheckMark(new_data->gauge->sty_3d),
  1102.                     Child, Label(GetStr(MCO_border)),
  1103.                     Child, new_data->CM_Border=CheckMark(new_data->gauge->sty_border),
  1104.                     Child, Label(GetStr(MCO_nobgcol)),
  1105.                     Child, new_data->CM_Bg=CheckMark(new_data->gauge->sty_bg),
  1106.                     Child, Label(GetStr(MCO_shadow)),
  1107.                     Child, new_data->CM_Shadow=CheckMark(new_data->gauge->sty_shadow),
  1108.                     Child, Label(GetStr(MCO_disgaug)),
  1109.                     Child, new_data->CM_NoGauge=CheckMark(new_data->gauge->sty_nogauge),
  1110.                     Child, Label(GetStr(MCO_disfmt)),
  1111.                     Child, new_data->CM_NoFmt=CheckMark(new_data->gauge->sty_noformat),
  1112.                     Child, Label(GetStr(MCO_disbas)),
  1113.                     Child, new_data->CM_NoBase=CheckMark(new_data->gauge->sty_nobase),
  1114.                     Child, VSpace(0),
  1115.                     Child, VSpace(0),
  1116.                 End,
  1117.                 Child, ColGroup(2),
  1118.                     Child, ColGroup(2),
  1119.                     Child, VSpace(0),
  1120.                     Child, VSpace(0),
  1121.                     Child, Label(GetStr(MCO_col_label)),
  1122.                     Child, new_data->CS_Colors[col_label]     =MakePen(),
  1123.                     Child, Label(GetStr(MCO_col_fmt)),
  1124.                     Child, new_data->CS_Colors[col_format]    =MakePen(),
  1125.                     Child, Label(GetStr(MCO_col_bas)),
  1126.                     Child, new_data->CS_Colors[col_base]      =MakePen(),
  1127.                     Child, Label(GetStr(MCO_col_cur)),
  1128.                     Child, new_data->CS_Colors[col_current]   =MakePen(),
  1129.                     Child, VSpace(0),
  1130.                     Child, VSpace(0),
  1131.                     End,
  1132.                     Child, ColGroup(2),
  1133.                     Child, VSpace(0),
  1134.                     Child, VSpace(0),
  1135.                     Child, Label(GetStr(MCO_col_neg)),
  1136.                     Child, new_data->CS_Colors[col_negative]  =MakePen(),
  1137.                     Child, Label(GetStr(MCO_col_bright)),
  1138.                     Child, new_data->CS_Colors[col_bright]    =MakePen(),
  1139.                     Child, Label(GetStr(MCO_col_dark)),
  1140.                     Child, new_data->CS_Colors[col_dark]      =MakePen(),
  1141.                     Child, Label(GetStr(MCO_col_bg)),
  1142.                     Child, new_data->CS_Colors[col_bg]        =MakePen(),
  1143.                     Child, VSpace(0),
  1144.                     Child, VSpace(0),
  1145.                     End,
  1146.                 End,
  1147.                 End,
  1148.             End,
  1149.             Child, HGroup, GroupFrameT(GetStr(MCO_fmt)),
  1150.                 Child, new_data->ST_Format=(Object *)String(0L,128),
  1151.                 Child, new_data->BT_Quest=BodychunkObject,
  1152.                 ButtonFrame,
  1153.                 MUIA_InputMode            , MUIV_InputMode_RelVerify,
  1154.                 MUIA_FixWidth             , QUESTION_WIDTH ,
  1155.                 MUIA_FixHeight            , QUESTION_HEIGHT,
  1156.                 MUIA_Bitmap_Width         , QUESTION_WIDTH ,
  1157.                 MUIA_Bitmap_Height        , QUESTION_HEIGHT,
  1158.                 MUIA_Bodychunk_Depth      , QUESTION_DEPTH ,
  1159.                 MUIA_Bodychunk_Body       , (UBYTE *)question_body,
  1160.                 MUIA_Bodychunk_Compression, QUESTION_COMPRESSION,
  1161.                 MUIA_Bodychunk_Masking    , QUESTION_MASKING,
  1162.                 MUIA_Bitmap_SourceColors  , (ULONG *)question_colors,
  1163.                 MUIA_Bitmap_Transparent   , 0,
  1164.                 End,
  1165.                 Child,  new_data->CY_Indent=CycleObject,
  1166.                 MUIA_Weight, 0,
  1167.                 MUIA_Cycle_Entries, indent,
  1168.                 End,
  1169.             End,
  1170.             Child, HGroup,
  1171.                 Child, new_data->BT_Use = (Object *)SimpleButton(GetStr(MCO_Use)),
  1172.                 Child, new_data->BT_Cancel = (Object *)SimpleButton(GetStr(MCO_Cancel)),
  1173.             End,
  1174.             End,
  1175.         End)
  1176.         {
  1177.         data=INST_DATA(cl,obj);
  1178.         CopyMem(new_data,data,sizeof(struct Composer_Data));
  1179.         FreeVec(new_data);
  1180.         set(data->ST_Label,MUIA_ShortHelp,GetStr(MOH_Label));
  1181.         set(data->PO_Device,MUIA_ShortHelp,GetStr(MOH_Device));
  1182.         set(data->CM_Border,MUIA_ShortHelp,GetStr(MOH_3d));
  1183.         set(data->CM_Bg,MUIA_ShortHelp,GetStr(MOH_Bg));
  1184.         set(data->CM_NoGauge,MUIA_ShortHelp,GetStr(MOH_NoGauge));
  1185.         set(data->CM_NoFmt,MUIA_ShortHelp,GetStr(MOH_NoFmt));
  1186.         set(data->CM_NoBase,MUIA_ShortHelp,GetStr(MOH_NoBase));
  1187.         insertComposerSettings(data->gauge,data);
  1188.         data->originator = (Object *)GetTagData(Originator,0,msg->ops_AttrList);
  1189.         DoMethod(data->LV_Device, MUIM_Notify,MUIA_Listview_DoubleClick      ,TRUE,obj,1,Dis_ID_DoubleClickDevice);
  1190.         DoMethod(data->CY_Type,   MUIM_Notify,MUIA_Cycle_Active,typ_gauge    ,data->ST_Label,3,MUIM_Set,MUIA_Disabled,FALSE);
  1191.         DoMethod(data->CY_Type,   MUIM_Notify,MUIA_Cycle_Active,typ_histmeter,data->ST_Label,3,MUIM_Set,MUIA_Disabled,TRUE);
  1192.         DoMethod(data->CY_Type,   MUIM_Notify,MUIA_Cycle_Active,typ_gauge    ,data->CM_3D,3,MUIM_Set,MUIA_Disabled,FALSE);
  1193.         DoMethod(data->CY_Type,   MUIM_Notify,MUIA_Cycle_Active,typ_histmeter,data->CM_3D,3,MUIM_Set,MUIA_Disabled,TRUE);
  1194.         DoMethod(data->CY_Type,   MUIM_Notify,MUIA_Cycle_Active,typ_gauge    ,data->CM_Shadow,3,MUIM_Set,MUIA_Disabled,FALSE);
  1195.         DoMethod(data->CY_Type,   MUIM_Notify,MUIA_Cycle_Active,typ_histmeter,data->CM_Shadow,3,MUIM_Set,MUIA_Disabled,TRUE);
  1196.         DoMethod(data->CY_Type,   MUIM_Notify,MUIA_Cycle_Active,typ_gauge    ,data->CM_Bg,3,MUIM_Set,MUIA_Disabled,FALSE);
  1197.         DoMethod(data->CY_Type,   MUIM_Notify,MUIA_Cycle_Active,typ_histmeter,data->CM_Bg,3,MUIM_Set,MUIA_Disabled,TRUE);
  1198.         if(data->gauge->type!=typ_clock_) DoMethod(data->BT_Quest,  MUIM_Notify,MUIA_Pressed,FALSE, WI_HelpFmt   ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  1199.         else                              DoMethod(data->BT_Quest,  MUIM_Notify,MUIA_Pressed,FALSE, WI_HelpClock ,3,MUIM_Set,MUIA_Window_Open,TRUE);
  1200.         DoMethod(obj,             MUIM_Notify,MUIA_Window_CloseRequest,TRUE, MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,3,Dis_ID_ComposerClose,obj,FALSE);
  1201.         DoMethod(data->BT_Cancel, MUIM_Notify,MUIA_Pressed,FALSE,            MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,3,Dis_ID_ComposerClose,obj,FALSE);
  1202.         DoMethod(data->BT_Use,    MUIM_Notify,MUIA_Pressed,FALSE,            MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,3,Dis_ID_ComposerClose,obj,TRUE);
  1203.         DoMethod(obj,       MUIM_Notify,MUIA_Window_MenuAction,CMP_SAVE,obj,1,Dis_ID_SaveGauge);
  1204.         DoMethod(obj,       MUIM_Notify,MUIA_Window_MenuAction,CMP_LOAD,obj,1,Dis_ID_LoadGauge);
  1205.         return((ULONG)obj);
  1206.         }
  1207.     }
  1208.     }
  1209.     return(0L);
  1210. }
  1211.  
  1212. static __saveds __asm ULONG ComposerDispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
  1213. {
  1214.     switch (msg->MethodID)
  1215.     {
  1216.     case OM_NEW                     : return(Composer_New   (cl,obj,(APTR)msg));
  1217.     case Dis_ID_ComposerSave        : return(Composer_Save  (cl,obj,(APTR)msg));
  1218.     case Dis_ID_DoubleClickDevice   : return(DoubleClickDev (cl,obj,(APTR)msg));
  1219.     case Dis_ID_SaveGauge           : return(SaveGaugeSet   (cl,obj));
  1220.     case Dis_ID_LoadGauge           : return(LoadGaugeSet   (cl,obj));
  1221.     }
  1222.     return(DoSuperMethodA(cl,obj,msg));
  1223. }
  1224. ///
  1225. /*************************************************/
  1226. /* Launcher Class                                */
  1227. /*************************************************/
  1228.  
  1229. /******************************************/
  1230. /* Launcher Menu                          */
  1231. /******************************************/
  1232. ///
  1233.  
  1234. struct NewMenu LauMenuData[] =
  1235. {
  1236.     { NM_TITLE, (STRPTR)MCM_Gauge          , 0 ,0 ,0             ,(APTR)CMP_PROJECT  },
  1237.     { NM_ITEM , (STRPTR)MCM_Open           ,"O",0 ,0             ,(APTR)CMP_LOAD     },
  1238.     { NM_ITEM , (STRPTR)MCM_SaveAs         ,"S",0 ,0             ,(APTR)CMP_SAVE     },
  1239.     { NM_ITEM ,  NM_BARLABEL               , 0 ,0 ,0             ,(APTR)0            },
  1240.     { NM_ITEM , (STRPTR)MCM_Cancel         ,"C",0 ,0             ,(APTR)CMP_CANCEL   },
  1241.     { NM_END,NULL,0,0,0,(APTR)0 }
  1242. };
  1243. ///
  1244. /******************************************/
  1245. /* Launcher class                         */
  1246. /******************************************/
  1247. ///
  1248. #define lind_realcenter     0
  1249. #define lind_center         1
  1250. #define lind_left           2
  1251. #define lind_right          3
  1252.  
  1253. #define launch_wb           0
  1254. #define launch_cli          1
  1255.  
  1256. #define Dis_ID_NewEntry     13
  1257. #define Dis_ID_RemoveEntry  14
  1258. #define Dis_ID_CloneEntry   15
  1259. #define Dis_ID_ChangeActive 16
  1260. #define Dis_ID_InsertActive 17
  1261. #define Dis_ID_LoadSet      19
  1262. #define Dis_ID_LoadStr      20
  1263. #define Dis_ID_SaveLauncher 21
  1264. #define Dis_ID_LoadLauncher 22
  1265.  
  1266. struct lau_entry
  1267. {
  1268.     char    lau_titl[32];
  1269.     char    lau_cmd[256];
  1270.     UWORD   lau_type;
  1271.     char    lau_pth[256];
  1272.     char    lau_out[256];
  1273.     char    lau_img[256];
  1274.     ULONG   lau_stack;
  1275. };
  1276.  
  1277. char   *reglauncher[]   ={(STRPTR)MCR_entries,(STRPTR)MCR_general,(STRPTR)MCR_colors,0L};
  1278. char   *cyplace[]       ={(STRPTR)MCR_up,(STRPTR)MCR_down,(STRPTR)MCR_over,0L};
  1279. char   *cyindent[]      ={(STRPTR)MCR_rightcenter,(STRPTR)MCR_center,(STRPTR)MCR_left,(STRPTR)MCR_right,0L};
  1280. char   *lau_type[]      ={"WB","CLI",0L};
  1281.  
  1282. __saveds __asm APTR lau_consfunc(__a1 struct lau_entry *src)
  1283. {
  1284.     return(src);
  1285. }
  1286. __saveds __asm ULONG lau_desfunc(__a1 struct lau_entry *src)
  1287. {
  1288.     return(FreeVec(src));
  1289. }
  1290. __saveds __asm void lau_dispfunc(__a2 char **array,__a1 struct lau_entry *src)
  1291. {
  1292.     *array++ = &src->lau_titl[0];
  1293.     *array++ = &src->lau_cmd[0];
  1294.     *array   = lau_type[src->lau_type];
  1295. }
  1296.  
  1297. static const struct Hook lau_ConstructHook = { { 0,0 }, (void *)lau_consfunc, NULL, NULL };
  1298. static const struct Hook lau_DestructHook  = { { 0,0 }, (void *)lau_desfunc , NULL, NULL };
  1299. static const struct Hook lau_DisplayHook   = { { 0,0 }, (void *)lau_dispfunc, NULL, NULL };
  1300.  
  1301. struct Launcher_Data
  1302. {
  1303.     struct tm_gau_set   *gauge;
  1304.     Object              *originator,
  1305.             *BT_Cancel,
  1306.             *BT_Use,
  1307.             *CS_Colors[8],
  1308.             *LAU_Menu,
  1309.             *LV_Entries,
  1310.             *ST_listfile,
  1311.             *CM_Xen,
  1312.             *CM_Bg,
  1313.             *CM_Shadow,
  1314.             *CM_Border,
  1315.             *CM_Transparent,
  1316.             *BT_New,
  1317.             *BT_Remove,
  1318.             *BT_Clone,
  1319.             *BT_Save,
  1320.             *BT_Reload,
  1321.             *ST_File,
  1322.             *ST_Title,
  1323.             *ST_Stack,
  1324.             *ST_Path,
  1325.             *ST_Out,
  1326.             *CY_File,
  1327.             *CY_Place,
  1328.             *CY_Indent,
  1329.             *NB_Height,
  1330.             *ST_Font,
  1331.             *ST_Label,
  1332.             *ST_Img,
  1333.             *ST_MImg;
  1334. };
  1335.  
  1336. struct LauncherFinishMsg
  1337. {
  1338.     ULONG   MethodID;
  1339.     Object  *win;
  1340.     ULONG   ok;
  1341. };
  1342.  
  1343. ULONG Launcher_Close(struct IClass *cl, Object *obj, struct LauncherFinishMsg *msg)
  1344. {
  1345.     if(msg->ok)
  1346.     {
  1347.     if(DoMethod(msg->win,Dis_ID_LauncherSave))
  1348.     {
  1349.         set(msg->win,MUIA_Window_Open,FALSE);
  1350.         DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_REMMEMBER,msg->win);
  1351.         MUI_DisposeObject(msg->win);
  1352.     }
  1353.     }
  1354.     else
  1355.     {
  1356.     set(msg->win,MUIA_Window_Open,FALSE);
  1357.     DoMethod((Object *)xget(obj,MUIA_ApplicationObject),OM_REMMEMBER,msg->win);
  1358.     MUI_DisposeObject(msg->win);
  1359.     }
  1360.     return((ULONG)0L);
  1361. }
  1362.  
  1363. insertLauncherSettings(struct tm_gau_set *gauge, struct Launcher_Data *data)
  1364. {
  1365.     int     i;
  1366.     char    dummy[256];
  1367.     for(i=0;i<8;i++) initColor(&gauge->Colors[i],data->CS_Colors[i]);
  1368.     set(data->CM_Xen     ,MUIA_Selected,        gauge->sty_3d);
  1369.     set(data->CM_Transparent,MUIA_Selected,     gauge->sty_noformat);
  1370.     set(data->CM_Border  ,MUIA_Selected,        gauge->sty_border);
  1371.     set(data->CM_Bg      ,MUIA_Selected,        gauge->sty_bg);
  1372.     set(data->CM_Shadow  ,MUIA_Selected,        gauge->sty_shadow);
  1373.     set(data->CY_Place   ,MUIA_Cycle_Active,    gauge->sty_nogauge);
  1374.     set(data->CY_Indent  ,MUIA_Cycle_Active,    gauge->indent);
  1375.     set(data->ST_listfile,MUIA_String_Contents, gauge->expansion);
  1376.     set(data->NB_Height,MUIA_Numeric_Value,gauge->size_y+100);
  1377.     strcpy(&dummy[0],gauge->font);
  1378.     sprintf((char *)&dummy[strlen(&dummy[0])-5],"/%d",gauge->font_size);
  1379.     set(data->ST_Font   ,MUIA_String_Contents,&dummy[0]);
  1380.     if(gauge->type==typ_iconlauncher)
  1381.     {
  1382.     set(data->ST_Font,      MUIA_Disabled, TRUE);
  1383.     set(data->NB_Height,    MUIA_Disabled, TRUE);
  1384.     set(data->CM_Xen,       MUIA_Disabled, TRUE);
  1385.     set(data->CM_Border,    MUIA_Disabled, TRUE);
  1386.     set(data->CM_Bg,        MUIA_Disabled, TRUE);
  1387.     set(data->CM_Shadow,    MUIA_Disabled, TRUE);
  1388.     set(data->CY_Place,     MUIA_Disabled, TRUE);
  1389.     set(data->ST_Label,     MUIA_Disabled, TRUE);
  1390.     set(data->ST_MImg,      MUIA_Disabled, TRUE);
  1391.     for(i=0;i<8;i++) set(data->CS_Colors[i],MUIA_Disabled,TRUE);
  1392.     }
  1393. }
  1394.  
  1395. saveLauncherSettings(struct Launcher_Data *data)
  1396. {
  1397.     int i;
  1398.     ULONG dummy;
  1399.     for(i=0;i<8;i++) getColor(&data->gauge->Colors[i],data->CS_Colors[i]);
  1400.     get(data->CM_Xen    ,MUIA_Selected       ,&dummy); data->gauge->sty_3d      =(UWORD)dummy;
  1401.     get(data->CM_Transparent,MUIA_Selected   ,&dummy); data->gauge->sty_noformat=(UWORD)dummy;
  1402.     get(data->CM_Border ,MUIA_Selected       ,&dummy); data->gauge->sty_border  =(UWORD)dummy;
  1403.     get(data->CM_Bg     ,MUIA_Selected       ,&dummy); data->gauge->sty_bg      =(UWORD)dummy;
  1404.     get(data->CM_Shadow ,MUIA_Selected       ,&dummy); data->gauge->sty_shadow  =(UWORD)dummy;
  1405.     get(data->CY_Place  ,MUIA_Cycle_Active   ,&dummy); data->gauge->sty_nogauge =(UWORD)dummy;
  1406.     get(data->CY_Indent ,MUIA_Cycle_Active   ,&dummy); data->gauge->indent      =(UWORD)dummy;
  1407.     get(data->ST_listfile,MUIA_String_Contents,&dummy); strcpy((char *)&data->gauge->expansion[0], dummy ? (char *)dummy : " " );
  1408.  
  1409.     get(data->NB_Height ,MUIA_Numeric_Value  ,&dummy); data->gauge->size_y      =(UWORD)dummy-100;
  1410.     get(data->ST_Font   ,MUIA_String_Contents,&dummy); sscanf((char *)dummy,"%[^/]/%d",&data->gauge->font[0],&i);
  1411.     strcat(&data->gauge->font[0],".font"); data->gauge->font_size=(WORD)i;
  1412.  
  1413.     DoMethod(visible,MUIM_List_Redraw,MUIV_List_Redraw_All);
  1414. }
  1415.  
  1416. LoadLauncherSet(struct IClass *cl,Object *obj)
  1417. {
  1418.     struct Launcher_Data    *data=INST_DATA(cl,obj);
  1419.     char                    *file;
  1420.     ULONG                   my_file;
  1421.     ULONG                   buf;
  1422.  
  1423.     if(file=getfilename(obj,GetStr(MCM_LoadGauge),"#?.tmgauge",FALSE))
  1424.     {
  1425.     if(my_file=(ULONG)Open(file,MODE_OLDFILE))
  1426.     {
  1427.         Read(my_file,&buf,4L);
  1428.         if(buf==0x544D4732)
  1429.         {
  1430.         Read(my_file,data->gauge,sizeof(struct tm_gau_set));
  1431.         insertLauncherSettings(data->gauge,data);
  1432.         DoMethod(obj,Dis_ID_LoadSet,0L);
  1433.         }
  1434.         else MUI_RequestA((Object *)xget(obj,MUIA_ApplicationObject),obj,0,"TinyMeterPrefs",GetStr(MCM_NotTmGauge_fmt),GetStr(MCM_NotTmGauge),NULL);
  1435.         Close(my_file);
  1436.     }
  1437.     }
  1438. }
  1439.  
  1440. SaveLauncherSet(struct IClass *cl,Object *obj)
  1441. {
  1442.     struct Launcher_Data        *data=INST_DATA(cl,obj);
  1443.     char                        *file;
  1444.     ULONG                       buf,my_file;
  1445.  
  1446.     saveLauncherSettings( data );
  1447.  
  1448.     buf=0x544D4732;
  1449.  
  1450.     if(file=getfilename(obj,GetStr(MCM_SaveGauge),"#?.tmgauge",TRUE))
  1451.     {
  1452.     if(my_file=Open(file,MODE_NEWFILE))
  1453.     {
  1454.         Write(my_file,&buf,4L);
  1455.         Write(my_file,data->gauge,sizeof(struct tm_gau_set));
  1456.         Close(my_file);
  1457.     }
  1458.     }
  1459. }
  1460.  
  1461. struct Launcher_Message
  1462. {
  1463.     ULONG   MethodID;
  1464. };
  1465.  
  1466. static struct lau_entry lau_default=
  1467. {
  1468.     "Empty",
  1469.     "",
  1470.     0,
  1471.     "",
  1472.     "",
  1473.     "",
  1474.     4096
  1475. };
  1476.  
  1477. Launcher_ChangeActive(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
  1478. {
  1479.     struct lau_entry        *entry;
  1480.     struct Launcher_Data    *data;
  1481.     data=INST_DATA(cl,obj);
  1482.  
  1483.     DoMethod(data->LV_Entries,MUIM_List_GetEntry,MUIV_List_GetEntry_Active, &entry);
  1484.     if(entry)
  1485.     {
  1486.     set(data->ST_File,  MUIA_String_Contents,   entry->lau_cmd);
  1487.     set(data->ST_Title, MUIA_String_Contents,   entry->lau_titl);
  1488.     set(data->ST_Path,  MUIA_String_Contents,   entry->lau_pth);
  1489.     set(data->ST_Out,   MUIA_String_Contents,   entry->lau_out);
  1490.     set(data->ST_Img,   MUIA_String_Contents,   entry->lau_img);
  1491.     set(data->ST_Stack, MUIA_String_Integer,    (ULONG)entry->lau_stack);
  1492.  
  1493.     // This MUST be the last!
  1494.     set(data->CY_File,  MUIA_Cycle_Active   ,   (ULONG)entry->lau_type);
  1495.     }
  1496. }
  1497.  
  1498. Launcher_InsertActive(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
  1499. {
  1500.     char                    *str,*foo,*dummy,*foobar,*klatuu;
  1501.     struct  lau_entry       *entry;
  1502.     ULONG                   active,stk;
  1503.     struct Launcher_Data    *data;
  1504.     data=INST_DATA(cl,obj);
  1505.  
  1506.     get(data->ST_File   ,MUIA_String_Contents,      &str);
  1507.     get(data->ST_Title  ,MUIA_String_Contents,      &foo);
  1508.     get(data->ST_Path   ,MUIA_String_Contents,      &dummy);
  1509.     get(data->ST_Out    ,MUIA_String_Contents,      &foobar);
  1510.     get(data->ST_Img    ,MUIA_String_Contents,      &klatuu);
  1511.     get(data->ST_Img    ,MUIA_String_Contents,      &klatuu);
  1512.     get(data->ST_Stack  ,MUIA_String_Integer,       &stk);
  1513.     get(data->CY_File   ,MUIA_Cycle_Active,         &active);
  1514.  
  1515.     DoMethod(data->LV_Entries,MUIM_List_GetEntry,MUIV_List_GetEntry_Active, &entry);
  1516.     if(entry)
  1517.     {
  1518.     strcpy(entry->lau_titl,foo);
  1519.     strcpy(entry->lau_cmd, str);
  1520.     strcpy(entry->lau_pth, dummy);
  1521.     strcpy(entry->lau_out, foobar);
  1522.     strcpy(entry->lau_img, klatuu);
  1523.     entry->lau_stack = stk;
  1524.     entry->lau_type  = (UWORD)active;
  1525.     DoMethod(data->LV_Entries,MUIM_List_Redraw,MUIV_List_Redraw_Active);
  1526.     }
  1527. }
  1528.  
  1529. __geta4 LONG AppMsgFunc(__A2 APTR obj, __A1 struct AppMessage **x)
  1530. {
  1531.     struct WBArg *ap;
  1532.     ULONG                   active;
  1533.     struct lau_entry        *entry;
  1534.     struct AppMessage *amsg = *x;
  1535.     int i;
  1536.     static char buf[256];
  1537.     char *b=buf;
  1538.  
  1539.     for (ap=amsg->am_ArgList,i=0;i<amsg->am_NumArgs;i++,ap++)
  1540.     {
  1541.  
  1542.         get(obj,MUIA_List_Active,&active);
  1543.         if(entry=(struct lau_entry *)AllocVec(sizeof(struct lau_entry),MEMF_CLEAR))
  1544.         {
  1545.         CopyMem(&lau_default,entry, sizeof(struct lau_entry));
  1546.  
  1547.         NameFromLock(ap->wa_Lock,buf,sizeof(buf));
  1548.         strcpy(entry->lau_pth, buf);
  1549.         strcpy(entry->lau_titl,ap->wa_Name);
  1550.         AddPart(buf,ap->wa_Name,sizeof(buf));
  1551.         strcpy(entry->lau_cmd, buf);
  1552.         entry->lau_type=0L;
  1553.  
  1554.         DoMethod(obj, MUIM_List_InsertSingle, entry,active);
  1555.         set     (obj, MUIA_List_Active,       active);
  1556.         }
  1557.     }
  1558.     return(0);
  1559. }
  1560.  
  1561. static const struct Hook AppMsgHook = { { NULL,NULL },(void *)AppMsgFunc,NULL,NULL };
  1562.  
  1563. Launcher_NewEntry(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
  1564. {
  1565.     ULONG                   active;
  1566.     struct lau_entry        *entry;
  1567.     struct Launcher_Data    *data;
  1568.     data=INST_DATA(cl,obj);
  1569.     get(data->LV_Entries,MUIA_List_Active,&active);
  1570.     if(entry=(struct lau_entry *)AllocVec(sizeof(struct lau_entry),MEMF_CLEAR))
  1571.     {
  1572.     CopyMem(&lau_default,entry, sizeof(struct lau_entry));
  1573.     DoMethod(data->LV_Entries, MUIM_List_InsertSingle, entry,active);
  1574.     set     (data->LV_Entries, MUIA_List_Active,       active);
  1575.     }
  1576. }
  1577.  
  1578. Launcher_RemoveEntry(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
  1579. {
  1580.     struct Launcher_Data    *data;
  1581.     data=INST_DATA(cl,obj);
  1582.     DoMethod(data->LV_Entries,MUIM_List_Remove,MUIV_List_Remove_Active);
  1583. }
  1584.  
  1585. Launcher_CloneEntry(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
  1586. {
  1587.     struct lau_entry        *desc,*news;
  1588.     struct Launcher_Data    *data;
  1589.     data=INST_DATA(cl,obj);
  1590.     DoMethod(data->LV_Entries,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&desc);
  1591.     if (desc)
  1592.     {
  1593.     if(news=AllocVec(sizeof(struct lau_entry),0L))
  1594.     {
  1595.         CopyMem(desc,news,sizeof(struct lau_entry));
  1596.         DoMethod(data->LV_Entries,MUIM_List_InsertSingle,news,MUIV_List_Insert_Active);
  1597.     }
  1598.     }
  1599. }
  1600.  
  1601. Launcher_CleanString(char *buffer)
  1602. {
  1603.     int i;
  1604.     if((i=strlen(buffer))<1)
  1605.     {
  1606.     buffer[0]=0x00;
  1607.     }
  1608.     else
  1609.     {
  1610.     if(buffer[i-1]==0x0a)
  1611.     {
  1612.         buffer[i-1]=0x00;
  1613.     }
  1614.     }
  1615. }
  1616.  
  1617. Launcher_LoadFromSettings(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
  1618. {
  1619.     BPTR                    file;
  1620.     char                    buffer[256];
  1621.     struct Launcher_Data    *data;
  1622.     struct  lau_entry       *entry;
  1623.  
  1624.     data=INST_DATA(cl,obj);
  1625.  
  1626.     if(file=(BPTR)Open(&data->gauge->expansion[0],MODE_OLDFILE))
  1627.     {
  1628.     if(FGets(file,&buffer[0],255))
  1629.     {
  1630.         if(*((ULONG *)&buffer[0])==0x544D4C49)
  1631.         {
  1632.         if(FGets(file,&buffer[0],255))
  1633.         {
  1634.             Launcher_CleanString(buffer);
  1635.             set(data->ST_Label,MUIA_String_Contents,&buffer[0]);
  1636.             if(FGets(file,&buffer[0],255))
  1637.             {
  1638.             Launcher_CleanString(buffer);
  1639.             set(data->ST_MImg,MUIA_String_Contents,&buffer[0]);
  1640.             while(FGets(file,&buffer[0],32))
  1641.             {
  1642.                 if(entry=(struct lau_entry *)AllocVec(sizeof(struct lau_entry),MEMF_CLEAR))
  1643.                 {
  1644.                 Launcher_CleanString(buffer);
  1645.                 strcpy(entry->lau_titl,buffer);
  1646.                 if(FGets(file,buffer,255))
  1647.                 {
  1648.                     Launcher_CleanString(buffer);
  1649.                     strcpy(entry->lau_cmd,buffer);
  1650.                     if(FGets(file,buffer,4))
  1651.                     {
  1652.                     entry->lau_type=*((UBYTE *)&buffer[0])-0x30;
  1653.                     if(FGets(file,buffer,255))
  1654.                     {
  1655.                         Launcher_CleanString(buffer);
  1656.                         strcpy(entry->lau_pth,buffer);
  1657.                         if(FGets(file,buffer,255))
  1658.                         {
  1659.                         Launcher_CleanString(buffer);
  1660.                         strcpy(entry->lau_out,buffer);
  1661.                         if(FGets(file,buffer,16))
  1662.                         {
  1663.                             Launcher_CleanString(buffer);
  1664.                             sscanf(buffer,"%ld",&entry->lau_stack);
  1665.                             if(FGets(file,buffer,255))
  1666.                             {
  1667.                             Launcher_CleanString(buffer);
  1668.                             strcpy(entry->lau_img,buffer);
  1669.                             }
  1670.                             else strcpy(entry->lau_out,"");
  1671.                         }
  1672.                         else entry->lau_stack=0;
  1673.                         }
  1674.                         else strcpy(entry->lau_out," ");
  1675.                     }
  1676.                     else strcpy(entry->lau_pth," ");
  1677.                     }
  1678.                     else entry->lau_type=0;
  1679.                 }
  1680.                 else strcpy(entry->lau_titl,"Empty");
  1681.                 DoMethod(data->LV_Entries, MUIM_List_InsertSingle, entry,MUIV_List_Insert_Bottom);
  1682.                 }
  1683.             }
  1684.             }
  1685.         }
  1686.         }
  1687.     }
  1688.     Close(file);
  1689.     }
  1690. }
  1691.  
  1692. Launcher_LoadFromString(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
  1693. {
  1694.     BPTR                    file;
  1695.     char                    *filename;
  1696.     char                    buffer[256];
  1697.     struct Launcher_Data    *data;
  1698.     struct  lau_entry       *entry;
  1699.  
  1700.     data=INST_DATA(cl,obj);;
  1701.  
  1702.     get(data->ST_listfile,MUIA_String_Contents,&filename);
  1703.     if(filename)
  1704.     {
  1705.     if(file=(BPTR)Open(filename,MODE_OLDFILE))
  1706.     {
  1707.         DoMethod(data->LV_Entries,MUIM_List_Clear,0L);
  1708.         if(FGets(file,&buffer[0],255))
  1709.         {
  1710.         if(*((ULONG *)&buffer[0])==0x544D4C49)
  1711.         {
  1712.             if(FGets(file,&buffer[0],255))
  1713.             {
  1714.             Launcher_CleanString(buffer);
  1715.             set(data->ST_Label,MUIA_String_Contents,&buffer[0]);
  1716.             if(FGets(file,&buffer[0],255))
  1717.             {
  1718.                 Launcher_CleanString(buffer);
  1719.                 set(data->ST_MImg,MUIA_String_Contents,&buffer[0]);
  1720.                 while(FGets(file,&buffer[0],32))
  1721.                 {
  1722.                 if(entry=(struct lau_entry *)AllocVec(sizeof(struct lau_entry),MEMF_CLEAR))
  1723.                 {
  1724.                     Launcher_CleanString(buffer);
  1725.                     strcpy(entry->lau_titl,buffer);
  1726.                     if(FGets(file,buffer,255))
  1727.                     {
  1728.                     Launcher_CleanString(buffer);
  1729.                     strcpy(entry->lau_cmd,buffer);
  1730.                     if(FGets(file,buffer,4))
  1731.                     {
  1732.                         entry->lau_type=*((UBYTE *)&buffer[0])-0x30;
  1733.                         if(FGets(file,buffer,255))
  1734.                         {
  1735.                         Launcher_CleanString(buffer);
  1736.                         strcpy(entry->lau_pth,buffer);
  1737.                         if(FGets(file,buffer,255))
  1738.                         {
  1739.                             Launcher_CleanString(buffer);
  1740.                             strcpy(entry->lau_out,buffer);
  1741.                             if(FGets(file,buffer,16))
  1742.                             {
  1743.                             Launcher_CleanString(buffer);
  1744.                             sscanf(buffer,"%ld",&entry->lau_stack);
  1745.                             if(FGets(file,buffer,255))
  1746.                             {
  1747.                                 Launcher_CleanString(buffer);
  1748.                                 strcpy(entry->lau_img,buffer);
  1749.                             }
  1750.                             else strcpy(entry->lau_out,"");
  1751.                             }
  1752.                             else entry->lau_stack=0;
  1753.                         }
  1754.                         else strcpy(entry->lau_out,"");
  1755.                         }
  1756.                         else strcpy(entry->lau_pth,"");
  1757.                     }
  1758.                     else entry->lau_type=0;
  1759.                     }
  1760.                     else strcpy(entry->lau_titl,"Empty");
  1761.                     DoMethod(data->LV_Entries, MUIM_List_InsertSingle, entry,MUIV_List_Insert_Bottom);
  1762.                 }
  1763.                 }
  1764.             }
  1765.             }
  1766.         }
  1767.         }
  1768.         Close(file);
  1769.     }
  1770.     }
  1771. }
  1772.  
  1773. ULONG Launcher_Save(struct IClass *cl,Object *obj,struct Launcher_Message *msg)
  1774. {
  1775.     int                 i;
  1776.     struct lau_entry    *entry;
  1777.     char                *filename,
  1778.             *label,
  1779.             buffer[256];
  1780.     BPTR                file;
  1781.     struct Launcher_Data *data;
  1782.  
  1783.     data=INST_DATA(cl,obj);
  1784.  
  1785.     get(data->ST_listfile,MUIA_String_Contents,&filename);
  1786.     if(filename&&filename[0])
  1787.     {
  1788.     if(strcmp(filename,"Provide a filename!")!=0)
  1789.     {
  1790.         if(file=(BPTR)Open(filename,MODE_NEWFILE))
  1791.         {
  1792.         FPuts(file,"TMLI\n");
  1793.  
  1794.         get(data->ST_Label,MUIA_String_Contents,&label);
  1795.         FPuts(file,label);
  1796.         FPutC(file,0x0a);
  1797.  
  1798.         get(data->ST_MImg,MUIA_String_Contents,&label);
  1799.         FPuts(file,label);
  1800.         FPutC(file,0x0a);
  1801.  
  1802.         for (i=0;;i++)
  1803.         {
  1804.             DoMethod(data->LV_Entries,MUIM_List_GetEntry,i,&entry);
  1805.             if (!entry) break;
  1806.             FPuts(file,entry->lau_titl);
  1807.             FPutC(file,0x0a);
  1808.             FPuts(file,entry->lau_cmd);
  1809.             FPutC(file,0x0a);
  1810.             FPutC(file,entry->lau_type+0x30);
  1811.             FPutC(file,0x0a);
  1812.             FPuts(file,entry->lau_pth);
  1813.             FPutC(file,0x0a);
  1814.             FPuts(file,entry->lau_out);
  1815.             FPutC(file,0x0a);
  1816.             sprintf(&buffer[0],"%0ld",entry->lau_stack);
  1817.             FPuts(file,&buffer[0]);
  1818.             FPutC(file,0x0a);
  1819.             FPuts(file,entry->lau_img);
  1820.             FPutC(file,0x0a);
  1821.         }
  1822.         Close(file);
  1823.         saveLauncherSettings(data);
  1824.         return(TRUE);
  1825.         }
  1826.     }
  1827.     }
  1828.     MUI_RequestA((Object *)xget(obj,MUIA_ApplicationObject),obj,0,"TinyMeterPrefs",GetStr(MOL_nofilename_fmt),GetStr(MOL_nofilename),NULL);
  1829.     return(FALSE);
  1830. }
  1831.  
  1832. static ULONG Launcher_New(struct IClass *cl,Object *obj,struct opSet *msg)
  1833. {
  1834.     struct Launcher_Data    *data,*new_data;
  1835.  
  1836.     if(new_data=AllocVec(sizeof(struct Launcher_Data),0L))
  1837.     {
  1838.     if(new_data->gauge = (struct tm_gau_set *)GetTagData(Gauge_Settings,0,msg->ops_AttrList))
  1839.     {
  1840.         if( obj = (Object *)DoSuperNew(cl,obj,
  1841.             MUIA_Window_Title       , gau_types[new_data->gauge->type] ,
  1842.             MUIA_Window_ID          , MAKE_ID('T','M','L','A'),
  1843.             MUIA_Window_Menustrip   , new_data->LAU_Menu = MUI_MakeObject(MUIO_MenustripNM,LauMenuData,0),
  1844.             MUIA_Window_AppWindow   , TRUE,
  1845.             WindowContents, VGroup, ButtonFrame,
  1846.             Child, HGroup,
  1847.                 Child, VGroup, MUIA_Background, MUII_SHADOW,
  1848.                 Child, VSpace(0),
  1849.                 Child, BodychunkObject,
  1850.                     MUIA_FixWidth             , HEADER_LOGO_WIDTH ,
  1851.                     MUIA_FixHeight            , HEADER_LOGO_HEIGHT,
  1852.                     MUIA_Bitmap_Width         , HEADER_LOGO_WIDTH ,
  1853.                     MUIA_Bitmap_Height        , HEADER_LOGO_HEIGHT,
  1854.                     MUIA_Bodychunk_Depth      , HEADER_LOGO_DEPTH ,
  1855.                     MUIA_Bodychunk_Body       , (UBYTE *)header_logo_body,
  1856.                     MUIA_Bodychunk_Compression, HEADER_LOGO_COMPRESSION,
  1857.                     MUIA_Bodychunk_Masking    , HEADER_LOGO_MASKING,
  1858.                     MUIA_Bitmap_SourceColors  , (ULONG *)header_logo_colors,
  1859.                     MUIA_Bitmap_Transparent   , 0,
  1860.                 End,
  1861.                 End,
  1862.                 Child, RegisterGroup(reglauncher),
  1863.                 MUIA_Register_Frame, TRUE,
  1864.                 Child, VGroup,
  1865.                     Child, VGroup,
  1866.                     Child, new_data->LV_Entries=(Object *)ListviewObject,
  1867.                         MUIA_Listview_Input, TRUE,
  1868.                         MUIA_Listview_DragType, 1,
  1869.                         MUIA_Dropable, FALSE,
  1870.                         MUIA_Listview_List, ListObject,
  1871.                         MUIA_Frame, MUIV_Frame_InputList,
  1872.                         MUIA_List_DragSortable, TRUE,
  1873.                         MUIA_List_ConstructHook, &lau_ConstructHook,
  1874.                         MUIA_List_DestructHook , &lau_DestructHook,
  1875.                         MUIA_List_DisplayHook  , &lau_DisplayHook,
  1876.                         MUIA_List_Format       , "BAR,MIW=5 MAW=100 BAR,",
  1877.                         MUIA_List_Active, MUIV_List_Active_Top,
  1878.                         End,
  1879.                     End,
  1880.                     Child, HGroup,
  1881.                         Child, Label(GetStr(MLO_Command)),
  1882.                         Child, new_data->ST_File=PopaslObject,
  1883.                         MUIA_Popstring_String, String(NULL,255),
  1884.                         MUIA_Popstring_Button, PopButton(MUII_PopFile),
  1885.                         ASLFO_TitleText  , GetStr(MLO_sel_listfile),
  1886.                         End,
  1887.                         Child, new_data->CY_File=CycleObject,
  1888.                         MUIA_Cycle_Entries, &lau_type[0],
  1889.                         MUIA_Weight, 0,
  1890.                         End,
  1891.                     End,
  1892.                     Child, ColGroup(4),
  1893.                         Child, Label(GetStr(MLO_Title)),
  1894.                         Child, new_data->ST_Title=String(0,32),
  1895.                         Child, Label(GetStr(MLO_Pic)),
  1896.                         Child, new_data->ST_Img=PopaslObject,
  1897.                         MUIA_Popstring_String, String(NULL,255),
  1898.                         MUIA_Popstring_Button, PopButton(MUII_PopFile),
  1899.                         ASLFO_TitleText  , GetStr(MLO_sel_listfile),
  1900.                         End,
  1901.                         Child, Label(GetStr(MLO_WorkDir)),
  1902.                         Child, new_data->ST_Path=PopaslObject,
  1903.                         MUIA_Popstring_String, String(NULL,255),
  1904.                         MUIA_Popstring_Button, PopButton(MUII_PopFile),
  1905.                         ASLFO_TitleText  , GetStr(MLO_sel_listfile),
  1906.                         End,
  1907.                         Child, Label(GetStr(MLO_OutPut)),
  1908.                         Child, new_data->ST_Out=String(NULL,32),
  1909.                         Child, Label(GetStr(MLO_Stack)),
  1910.                         Child, new_data->ST_Stack=StringObject,
  1911.                         StringFrame,
  1912.                         MUIA_String_Accept,     "0123456789",
  1913.                         MUIA_String_MaxLen,     32,
  1914.                         MUIA_String_Contents,   NULL,
  1915.                         End,
  1916.                         Child, HVSpace,
  1917.                         Child, HVSpace,
  1918.                     End,
  1919.                     Child, ColGroup(3),
  1920.                         Child,  new_data->BT_New=SimpleButton(GetStr(MLO_New)),
  1921.                         Child,  new_data->BT_Remove=SimpleButton(GetStr(MLO_Remove)),
  1922.                         Child,  new_data->BT_Clone=SimpleButton(GetStr(MLO_Clone)),
  1923.                     End,
  1924.                     End,
  1925.                 End,
  1926.                 Child, VGroup,
  1927.                     MUIA_Group_SameWidth,FALSE,
  1928.                     Child, ColGroup(2),
  1929.                     Child, Label(GetStr(MCO_xen)),
  1930.                     Child, HGroup, Child, new_data->CM_Xen=CheckMark(new_data->gauge->sty_3d), Child, HVSpace, End,
  1931.                     Child, Label(GetStr(MCO_transparent)),
  1932.                     Child, HGroup, Child, new_data->CM_Transparent=CheckMark(new_data->gauge->sty_noformat), Child, HVSpace, End,
  1933.                     Child, Label(GetStr(MCO_slabel)),
  1934.                     Child, HGroup, Child, new_data->CM_Shadow=CheckMark(new_data->gauge->sty_shadow), Child, HVSpace, End,
  1935.                     Child, Label(GetStr(MCO_background)),
  1936.                     Child, HGroup, Child, new_data->CM_Bg=CheckMark(new_data->gauge->sty_bg), Child, HVSpace, End,
  1937.                     Child, Label(GetStr(MCO_border)),
  1938.                     Child, HGroup, Child, new_data->CM_Border=CheckMark(new_data->gauge->sty_border), Child, HVSpace, End,
  1939.                     Child, Label(GetStr(MCO_place)),
  1940.                     Child, HGroup, Child, new_data->CY_Place=CycleObject,
  1941.                         MUIA_Cycle_Entries, &cyplace[0],
  1942.                     End, Child, HVSpace, End,
  1943.                     Child, Label(GetStr(MCR_poslabel)),
  1944.                     Child, HGroup, Child, new_data->CY_Indent=CycleObject,
  1945.                         MUIA_Cycle_Entries, &cyindent[0],
  1946.                     End, Child, HVSpace, End,
  1947.                     Child, Label(GetStr(MCO_height)),
  1948.                     Child, ColGroup(2), Child, new_data->NB_Height=MUI_MakeObject(MUIO_NumericButton,NULL,100,1000,GetStr(MCO_height_fmt)), Child, HVSpace, End,
  1949.                     Child, Label(GetStr(MCO_font)),
  1950.                     Child,  PopaslObject,
  1951.                         MUIA_Popstring_String, new_data->ST_Font=(Object *)String(0L,80),
  1952.                         MUIA_Popstring_Button, PopButton(MUII_PopUp),
  1953.                         MUIA_Popasl_Type , ASL_FontRequest,
  1954.                         ASLFO_TitleText  , GetStr(MCO_sel_font),
  1955.                     End,
  1956.                     End,
  1957.                 End,
  1958.  
  1959.                 Child, ColGroup(2), 
  1960.                     Child, ColGroup(2),
  1961.                     Child, VSpace(0),
  1962.                     Child, VSpace(0),
  1963.                     Child, Label(GetStr(MCO_col_label)),
  1964.                     Child, new_data->CS_Colors[col_label]     =MakePen(),
  1965.                     Child, Label(GetStr(MCO_col_entry)),
  1966.                     Child, new_data->CS_Colors[col_format]    =MakePen(),
  1967.                     Child, Label(GetStr(MCO_col_hbright)),
  1968.                     Child, new_data->CS_Colors[col_base]      =MakePen(),
  1969.                     Child, Label(GetStr(MCO_col_hdark)),
  1970.                     Child, new_data->CS_Colors[col_current]   =MakePen(),
  1971.                     Child, VSpace(0),
  1972.                     Child, VSpace(0),
  1973.                     End,
  1974.  
  1975.                     Child, ColGroup(2),
  1976.                     Child, VSpace(0),
  1977.                     Child, VSpace(0),
  1978.                     Child, Label(GetStr(MCO_col_cursor)),
  1979.                     Child, new_data->CS_Colors[col_negative]  =MakePen(),
  1980.                     Child, Label(GetStr(MCO_col_bright)),
  1981.                     Child, new_data->CS_Colors[col_bright]    =MakePen(),
  1982.                     Child, Label(GetStr(MCO_col_dark)),
  1983.                     Child, new_data->CS_Colors[col_dark]      =MakePen(),
  1984.                     Child, Label(GetStr(MCO_col_bg)),
  1985.                     Child, new_data->CS_Colors[col_bg]        =MakePen(),
  1986.                     Child, VSpace(0),
  1987.                     Child, VSpace(0),
  1988.                     End,
  1989.                 End,
  1990.                 End,
  1991.             End,
  1992.             Child, VGroup,
  1993.                 Child, ColGroup(2), GroupFrame,
  1994.                 Child, Label(GetStr(MCO_label)),
  1995.                 Child, ColGroup(3),
  1996.                     Child, new_data->ST_Label=String(0L,16),
  1997.                     Child, Label(GetStr(MLO_Pic)),
  1998.                     Child, new_data->ST_MImg=PopaslObject,
  1999.                     MUIA_Popstring_String, String(NULL,255),
  2000.                     MUIA_Popstring_Button, PopButton(MUII_PopFile),
  2001.                     ASLFO_TitleText  , GetStr(MLO_sel_picfile),
  2002.                     End,
  2003.                 End,
  2004.                 Child, Label(GetStr(MLO_listfile)),
  2005.                 Child, HGroup,
  2006.                     Child, new_data->ST_listfile=PopaslObject,
  2007.                     MUIA_Popstring_String, String(NULL,255),
  2008.                     MUIA_Popstring_Button, PopButton(MUII_PopFile),
  2009.                     ASLFO_TitleText  , GetStr(MLO_sel_listfile),
  2010.                     End,
  2011.                     Child, new_data->BT_Reload=TextObject,
  2012.                     ButtonFrame,
  2013.                     MUIA_Text_Contents, GetStr(MLO_Load),
  2014.                     MUIA_Text_PreParse, "\33c",
  2015.                     MUIA_InputMode    , MUIV_InputMode_RelVerify,
  2016.                     MUIA_Background   , MUII_ButtonBack,
  2017.                     MUIA_Weight,        0,
  2018.                     End,
  2019.                 End,
  2020.                 End,
  2021.                 Child, HGroup,
  2022.                 Child, new_data->BT_Save    = (Object *)SimpleButton(GetStr(MLO_Save)),
  2023.                 Child, new_data->BT_Cancel  = (Object *)SimpleButton(GetStr(MCO_Cancel)),
  2024.                 End,
  2025.             End,
  2026.             End,
  2027.         End)
  2028.         {
  2029.         data=INST_DATA(cl,obj);
  2030.  
  2031.         set(data->ST_Stack,MUIA_ShortHelp,GetStr(MOL_Stack));
  2032.         set(data->ST_Out,MUIA_ShortHelp,GetStr(MOL_Out));
  2033.         set(data->ST_listfile,MUIA_ShortHelp,GetStr(MOL_listfile));
  2034.  
  2035.         CopyMem(new_data,data,sizeof(struct Launcher_Data));
  2036.         FreeVec(new_data);
  2037.  
  2038.         data->originator = (Object *)GetTagData(Originator,0,msg->ops_AttrList);
  2039.  
  2040.         insertLauncherSettings(data->gauge,data);
  2041.  
  2042.         DoMethod(obj,Dis_ID_LoadSet,0L);
  2043.  
  2044.         DoMethod(obj,             MUIM_Notify,MUIA_Window_CloseRequest,TRUE, MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,4,Dis_ID_LauncherClose,obj,FALSE,data->ST_listfile);
  2045.         DoMethod(data->BT_Cancel, MUIM_Notify,MUIA_Pressed,FALSE,            MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,4,Dis_ID_LauncherClose,obj,FALSE,data->ST_listfile);
  2046.         DoMethod(data->BT_Save,   MUIM_Notify,MUIA_Pressed,FALSE,            MUIV_Notify_Application,6,MUIM_Application_PushMethod,data->originator,4,Dis_ID_LauncherClose,obj,TRUE, data->ST_listfile);
  2047.         DoMethod(data->BT_New,    MUIM_Notify,MUIA_Pressed,FALSE,                       obj,1,Dis_ID_NewEntry);
  2048.         DoMethod(data->BT_Remove, MUIM_Notify,MUIA_Pressed,FALSE,                       obj,1,Dis_ID_RemoveEntry);
  2049.         DoMethod(data->BT_Clone,  MUIM_Notify,MUIA_Pressed,FALSE,                       obj,1,Dis_ID_CloneEntry);
  2050.         DoMethod(data->BT_Reload, MUIM_Notify,MUIA_Pressed,FALSE,                       obj,1,Dis_ID_LoadStr);
  2051.         DoMethod(data->LV_Entries,MUIM_Notify,MUIA_List_Active,MUIV_EveryTime,          obj,1,Dis_ID_ChangeActive);
  2052.         DoMethod(data->ST_File,   MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,   obj,1,Dis_ID_InsertActive);
  2053.         DoMethod(data->ST_Title,  MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,   obj,1,Dis_ID_InsertActive);
  2054.         DoMethod(data->ST_Stack,  MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,   obj,1,Dis_ID_InsertActive);
  2055.         DoMethod(data->ST_Path,   MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,   obj,1,Dis_ID_InsertActive);
  2056.         DoMethod(data->ST_Img,    MUIM_Notify,MUIA_String_Acknowledge,MUIV_EveryTime,   obj,1,Dis_ID_InsertActive);
  2057.         DoMethod(data->CY_File,   MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,         obj,1,Dis_ID_InsertActive);
  2058.  
  2059.         DoMethod(data->LV_Entries,MUIM_Notify,MUIA_AppMessage,MUIV_EveryTime,data->LV_Entries,3,MUIM_CallHook,&AppMsgHook,MUIV_TriggerValue);
  2060.  
  2061.         set(data->ST_Out,MUIA_Disabled,TRUE);
  2062.         DoMethod(data->CY_File,   MUIM_Notify,MUIA_Cycle_Active,0,data->ST_Out,3,MUIM_Set,MUIA_Disabled,TRUE);
  2063.         DoMethod(data->CY_File,   MUIM_Notify,MUIA_Cycle_Active,1,data->ST_Out,3,MUIM_Set,MUIA_Disabled,FALSE);
  2064.  
  2065.         DoMethod(obj, MUIM_Notify,MUIA_Window_MenuAction,CMP_SAVE,obj,1,Dis_ID_SaveLauncher);
  2066.         DoMethod(obj, MUIM_Notify,MUIA_Window_MenuAction,CMP_LOAD,obj,1,Dis_ID_LoadLauncher);
  2067.  
  2068.         return((ULONG)obj);
  2069.         }
  2070.     }
  2071.     }
  2072.     return(0L);
  2073. }
  2074.  
  2075. static __saveds __asm ULONG LauncherDispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
  2076. {
  2077.     switch (msg->MethodID)
  2078.     {
  2079.     case OM_NEW                     : return(Launcher_New(cl,obj,(APTR)msg));
  2080.     case Dis_ID_NewEntry            : return(Launcher_NewEntry(cl,obj,(APTR)msg));
  2081.     case Dis_ID_RemoveEntry         : return(Launcher_RemoveEntry(cl,obj,(APTR)msg));
  2082.     case Dis_ID_CloneEntry          : return(Launcher_CloneEntry(cl,obj,(APTR)msg));
  2083.     case Dis_ID_ChangeActive        : return(Launcher_ChangeActive(cl,obj,(APTR)msg));
  2084.     case Dis_ID_InsertActive        : return(Launcher_InsertActive(cl,obj,(APTR)msg));
  2085.     case Dis_ID_LauncherSave        : return(Launcher_Save(cl,obj,(APTR)msg));
  2086.     case Dis_ID_LoadStr             : return(Launcher_LoadFromString(cl,obj,(APTR)msg));
  2087.     case Dis_ID_LoadSet             : return(Launcher_LoadFromSettings(cl,obj,(APTR)msg));
  2088.     case Dis_ID_SaveLauncher        : return(SaveLauncherSet(cl,obj));
  2089.     case Dis_ID_LoadLauncher        : return(LoadLauncherSet(cl,obj));
  2090.     }
  2091.     return(DoSuperMethodA(cl,obj,msg));
  2092. }
  2093. ///
  2094. /*************************************************/
  2095. /* Main Window and his dispatcher                */
  2096. /*************************************************/
  2097.  
  2098. /******************************************/
  2099. /* some vars                              */
  2100. /******************************************/
  2101. ///
  2102. #define Dis_ID_DoubleClick1 1
  2103. #define Dis_ID_Finish       2
  2104. #define Dis_ID_DoubleClick2 3
  2105. #define Dis_ID_Save         4
  2106. #define Dis_ID_Snap         5
  2107. #define Dis_ID_Load         6
  2108.  
  2109. struct NewMenu MenuData1[] =
  2110. {
  2111.     { NM_TITLE, (STRPTR)MM_Project         , 0 ,0 ,0             ,(APTR)MEN_PROJECT  },
  2112.     { NM_ITEM , (STRPTR)MM_Open            ,"O",0 ,0             ,(APTR)MEN_OPEN     },
  2113.     { NM_ITEM , (STRPTR)MM_SaveAs          ,"S",0 ,0             ,(APTR)MEN_SAVE     },
  2114.     { NM_ITEM , (STRPTR)MM_About           ,"?",0 ,0             ,(APTR)MEN_ABOUT    },
  2115.     { NM_ITEM ,  NM_BARLABEL               , 0 ,0 ,0             ,(APTR)0            },
  2116.     { NM_ITEM , (STRPTR)MM_Quit            ,"Q",0 ,0             ,(APTR)MEN_QUIT     },
  2117.     { NM_END,NULL,0,0,0,(APTR)0 }
  2118. };
  2119.  
  2120. struct ls_layout
  2121. {
  2122.     char    *entry_desc;
  2123.     BYTE     entry_selected;
  2124.     BOOL     entry_max;
  2125.     char    *entry[6];
  2126. };
  2127.  
  2128. struct  ls_layout switches[]=
  2129. {
  2130.     {(STRPTR)ML_Window,         0,0,0,0,0,0,0,0},
  2131.     {(STRPTR)ML_BgPic,          0,2,(STRPTR)ML_BgPic_None,(STRPTR)ML_BgPic_File,(STRPTR)ML_BgPic_Snap,0,0,0},
  2132.     {(STRPTR)ML_WinBeh,         0,2,(STRPTR)ML_WinBeh_Normal,(STRPTR)ML_WinBeh_Front,(STRPTR)ML_WinBeh_Back,0,0,0},
  2133.     {(STRPTR)ML_WinMov,         0,1,(STRPTR)ML_WinMov_Normal,(STRPTR)ML_WinMov_Fixed,0,0,0,0},
  2134.     {(STRPTR)ML_Border,         0,3,(STRPTR)ML_Border_None,(STRPTR)ML_Border_Simple,(STRPTR)ML_Border_Standard,(STRPTR)ML_Border_Double,0,0},
  2135.     {(STRPTR)ML_Startup,        0,0,0,0,0,0,0,0},
  2136.     {(STRPTR)ML_ScrNot,         0,1,(STRPTR)ML_ScrNot_No,(STRPTR)ML_ScrNot_Yes,0,0,0,0},
  2137.     {(STRPTR)ML_Cpu,            0,2,(STRPTR)ML_Cpu_None,(STRPTR)ML_Cpu_Executive,(STRPTR)ML_Cpu_Own,0,0,0},
  2138.     NULL
  2139. };
  2140.  
  2141. char    *mainlister[]=
  2142. {
  2143.     (STRPTR)MOL_General,
  2144.     (STRPTR)MOL_Compose,
  2145.     NULL
  2146. };
  2147.  
  2148. char    *sublister[]=
  2149. {
  2150.     (STRPTR)MOL_sub_General,
  2151.     (STRPTR)MOL_sub_Flags,
  2152.     (STRPTR)MOL_sub_Window,
  2153.     NULL
  2154. };
  2155.  
  2156. struct MainData
  2157. {
  2158.     ULONG   dummy;
  2159. };
  2160.  
  2161. char    *pubscr[256];
  2162.  
  2163. Object  *BT_Save,
  2164.     *BT_Use,
  2165.     *BT_Test,
  2166.     *BT_Cancel,
  2167.     *ls_Switch,
  2168.     *ls_PubScr,
  2169.     *lv_Switch,
  2170.     *lv_PubScr,
  2171.     *ST_PubScr,
  2172.     *PO_PubScr,
  2173.     *MN_Main,
  2174.     *WI_About,
  2175.     *IN_posx,
  2176.     *IN_posy,
  2177.     *IN_sizx,
  2178.     *ST_bg,
  2179.     *NB_wait,
  2180.     *NB_mem,
  2181.     *NB_vol,
  2182.     *NB_bordx,
  2183.     *NB_bordy,
  2184.     *NB_spcx,
  2185.     *NB_spcy,
  2186.     *NB_col,
  2187.     *NB_pri,
  2188.     *MN_Colors[3],
  2189.     *CM_Falling,
  2190.     *BT_Snap,
  2191.     *LV_Composer;
  2192.  
  2193. ///
  2194. /******************************************/
  2195. /* some listview hooks                    */
  2196. /******************************************/
  2197. ///
  2198. __saveds __asm APTR lay_consfunc(__a1 struct ls_layout *src) { return(src); }
  2199.  
  2200. __saveds __asm ULONG lay_desfunc(__a1 struct ls_layout *src) { return(0L);  }
  2201.  
  2202. __saveds __asm void lay_dispfunc(__a2 char **array,__a1 struct ls_layout *src)
  2203. {
  2204.     *array++ = src->entry_desc;
  2205.     *array   = src->entry[src->entry_selected];
  2206. }
  2207.  
  2208. static const struct Hook lay_ConstructHook = { { 0,0 }, (void *)lay_consfunc, NULL, NULL };
  2209. static const struct Hook lay_DestructHook  = { { 0,0 }, (void *)lay_desfunc , NULL, NULL };
  2210. static const struct Hook lay_DisplayHook   = { { 0,0 }, (void *)lay_dispfunc, NULL, NULL };
  2211. ///
  2212. /******************************************/
  2213. /* load settings and a method             */
  2214. /******************************************/
  2215. ///
  2216. #define load_standard  0
  2217. #define load_file      1
  2218.  
  2219. struct LoadSetMsg
  2220. {
  2221.     ULONG           MethodID;
  2222.     ULONG           what;
  2223. };
  2224.  
  2225. insertSettings(struct tm_sys_set *set,struct tm_gau_set *list)
  2226. {
  2227.     struct ls_layout *src;
  2228.  
  2229.     set(NB_col  ,MUIA_Numeric_Value,set->colums);
  2230.     set(NB_bordx,MUIA_Numeric_Value,set->win_border_x);
  2231.     set(NB_bordy,MUIA_Numeric_Value,set->win_border_y);
  2232.     set(NB_spcx ,MUIA_Numeric_Value,set->win_space_x);
  2233.     set(NB_spcy ,MUIA_Numeric_Value,set->win_space_y);
  2234.     set(NB_wait ,MUIA_Numeric_Value,set->start_wait);
  2235.     set(NB_mem  ,MUIA_Numeric_Value,set->mem_refresh);
  2236.     set(NB_vol  ,MUIA_Numeric_Value,set->vol_refresh);
  2237.     set(NB_pri  ,MUIA_Numeric_Value,set->pri);
  2238.  
  2239.     DoMethod(ls_Switch,MUIM_List_GetEntry,1,&src);
  2240.     src->entry_selected=set->bg_type;
  2241.     DoMethod(ls_Switch,MUIM_List_GetEntry,2,&src);
  2242.     src->entry_selected=set->win_backfront;
  2243.     DoMethod(ls_Switch,MUIM_List_GetEntry,3,&src);
  2244.     src->entry_selected=set->win_move;
  2245.     DoMethod(ls_Switch,MUIM_List_GetEntry,4,&src);
  2246.     src->entry_selected=set->bd_type;
  2247.     DoMethod(ls_Switch,MUIM_List_GetEntry,6,&src);
  2248.     src->entry_selected=set->start_usescreennotify;
  2249.     DoMethod(ls_Switch,MUIM_List_GetEntry,7,&src);
  2250.     src->entry_selected=set->Executive;
  2251.  
  2252.     initColor(&set->bg_color,MN_Colors[0]);
  2253.     initColor(&set->bright_color,MN_Colors[1]);
  2254.     initColor(&set->dark_color,MN_Colors[2]);
  2255.  
  2256.     set(ST_PubScr,  MUIA_String_Contents    ,&set->pub_name[0]);
  2257.     set(IN_posx,    MUIA_String_Integer     ,set->x_pos);
  2258.     set(IN_posy,    MUIA_String_Integer     ,set->y_pos);
  2259.     set(IN_sizx,    MUIA_String_Integer     ,set->x_siz);
  2260.     set(ST_bg,      MUIA_String_Contents    ,&set->bg_picture[0]);
  2261.     set(CM_Falling, MUIA_Selected           ,set->lay_falling);
  2262.  
  2263.     DoMethod(visible,MUIM_List_Clear,0L);
  2264.     do
  2265.     {
  2266.     DoMethod(visible,MUIM_List_InsertSingle,list,MUIV_List_Insert_Bottom);
  2267.     }
  2268.     while(list=list->next);
  2269.     DoMethod(visible,MUIM_List_Redraw,MUIV_List_Redraw_All);
  2270.     DoMethod(ls_Switch,MUIM_List_Redraw,MUIV_List_Redraw_All);
  2271. }
  2272.  
  2273. int getNum(struct tm_gau_set *list)
  2274. {
  2275.     int num=1;
  2276.     while(list=list->next)num++;
  2277.     return(num);
  2278. }
  2279.  
  2280. useDefault(struct tm_data *data)
  2281. {
  2282.     struct tm_gau_set   *many,
  2283.             *act,
  2284.             *old;
  2285.  
  2286.     CopyMem((char *)&default_set,data->set,sizeof(struct tm_sys_set));
  2287.     
  2288.     if(act=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),0L))
  2289.     {
  2290.     many=&g1; data->list=act; CopyMem((char *)many,act,sizeof(struct tm_gau_set));
  2291.     while(many=many->next)
  2292.     {
  2293.         old=act;
  2294.         if(act=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),0L))
  2295.         {
  2296.         old->next=act;
  2297.         CopyMem((char *)many,act,sizeof(struct tm_gau_set));
  2298.         }
  2299.         else {act->next=0L;return;}
  2300.     }
  2301.     act->next=0L;
  2302.     }
  2303.     else data->list=0L;
  2304. }
  2305.  
  2306.  
  2307. BOOL loadSettings(Object *obj,struct tm_data *data, char *file)
  2308. {
  2309.     ULONG  my_file;
  2310.     struct tm_gau_set *many,*act;
  2311.  
  2312.     if(!maindata->set)maindata->set=AllocVec(sizeof(struct tm_sys_set),0L);
  2313.  
  2314.     if(my_file=(UBYTE *)Open(file,MODE_OLDFILE))
  2315.     {
  2316.     if(!Read(my_file,data->set,(ULONG)sizeof(struct tm_sys_set)))
  2317.     {
  2318.         useDefault(data);
  2319.     }
  2320.     else
  2321.     {
  2322.         act=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),NULL);
  2323.         data->list=act; many=act;
  2324.         while(Read(my_file,(char *)act,(ULONG)sizeof(struct tm_gau_set)))
  2325.         {
  2326.         many=act;
  2327.         act=(struct tm_gau_set *)AllocVec(sizeof(struct tm_gau_set),NULL);
  2328.         many->next=act;
  2329.         }
  2330.         many->next=NULL; FreeVec(act); act=NULL;
  2331.     }
  2332.     Close(my_file);
  2333.     }
  2334.     else useDefault(data);
  2335.  
  2336.     data->num_of_gaug=getNum(data->list);
  2337. }
  2338.  
  2339. ULONG loadManager(struct IClass *cl,Object *obj, struct LoadSetMsg *msg)
  2340. {
  2341.     char *file;
  2342.     switch (msg->what)
  2343.     {
  2344.     case    load_standard:
  2345.         loadSettings(obj,maindata,"ENV:TinyMeter");
  2346.         insertSettings(maindata->set,maindata->list);
  2347.         break;
  2348.     case    load_file:
  2349.         if(file=getfilename(obj,GetStr(MM_OpenTitle),"#?.tm",FALSE))
  2350.         {
  2351.             loadSettings(obj,maindata,file);
  2352.             insertSettings(maindata->set,maindata->list);
  2353.         }
  2354.         break;
  2355.     }
  2356.     return((ULONG)DoSuperMethodA(cl,obj,msg));
  2357. }
  2358.  
  2359. ///
  2360. /******************************************/
  2361. /* test settings and window snapping      */
  2362. /******************************************/
  2363. ///
  2364.  
  2365. #include <exec/memory.h>
  2366. #include <exec/ports.h>
  2367. #include <exec/execbase.h>
  2368.  
  2369. #define test_test       0
  2370. #define test_getwin     1
  2371.  
  2372. struct TestMessage
  2373. {
  2374.     struct  Message ts_Message;
  2375.  
  2376.     ULONG   MethodID;
  2377.  
  2378.     struct  tm_sys_set  *set;
  2379.     struct  tm_gau_set  *list;
  2380.  
  2381.     ULONG   posx,
  2382.         posy,
  2383.         sizx;
  2384. };
  2385.  
  2386. struct TestMessage  *ts_msg;
  2387. struct MsgPort      *p_port;
  2388. struct MsgPort      *p_reply;
  2389.  
  2390. BOOL SafePutToPort(struct Message *message, char *portname)
  2391. {
  2392.     struct MsgPort *port;
  2393.  
  2394.     Forbid();
  2395.     port = (struct MsgPort *)FindPort(portname);
  2396.     if (port) PutMsg(port, (struct Message *) message);
  2397.     Permit();
  2398.     return(port ? TRUE : FALSE);
  2399. }
  2400.  
  2401. ULONG InitTestSettings()
  2402. {
  2403.     if(
  2404.        ( ts_msg =(struct TestMessage *)AllocMem  (sizeof(struct TestMessage),MEMF_PUBLIC|MEMF_CLEAR)) &&
  2405.        ( p_reply=(struct MsgPort *)    CreatePort(0,0))
  2406.       )  return (1L);
  2407.     else return (0L);
  2408. }
  2409.  
  2410. FreeTestSettings()
  2411. {
  2412.     if(ts_msg) FreeMem      (ts_msg,sizeof(struct TestMessage));
  2413.     if(p_reply)DeletePort   (p_reply);
  2414. }
  2415.  
  2416. struct TestMessage *TestSettings(ULONG type)
  2417. {
  2418.     ULONG  i,j;
  2419.     struct tm_gau_set   *act,
  2420.             *all[64];
  2421.     if( FindPort("TinyMeter") )
  2422.     if( ts_msg && p_reply)
  2423.     {
  2424.     ts_msg->ts_Message.mn_Node.ln_Type  = NT_MESSAGE;
  2425.     ts_msg->ts_Message.mn_ReplyPort     = p_reply;
  2426.     ts_msg->ts_Message.mn_Length        = sizeof ( struct TestMessage );
  2427.     ts_msg->MethodID                    = type;
  2428.     switch (type)
  2429.     {
  2430.         case    test_test:
  2431.             for(i=0;i<64;i++)all[i]=0L;
  2432.             for(i=0;;i++)
  2433.             {
  2434.             DoMethod(visible,MUIM_List_GetEntry,i,&act);
  2435.             if(!act)  break;
  2436.             if(i==63) break;
  2437.             if(all[i]=AllocVec(sizeof(struct tm_gau_set),0L))
  2438.             {
  2439.                 CopyMem(act, all[i], sizeof(struct tm_gau_set));
  2440.             }
  2441.             else return(0L);
  2442.             }
  2443.             for(j=0;j<i;j++)
  2444.             {
  2445.             all[j]->next=all[j+1];
  2446.             }
  2447.             ts_msg->list=all[0];
  2448.  
  2449.             if(ts_msg->set = AllocVec(sizeof(struct tm_sys_set),0L))
  2450.             {
  2451.             CopyMem(maindata->set,ts_msg->set,sizeof(struct tm_sys_set));
  2452.             }
  2453.             else return(0L);
  2454.             break;
  2455.         case    test_getwin:
  2456.             ts_msg->list=0L;
  2457.             ts_msg->set =0L;
  2458.             break;
  2459.     }
  2460.     if (SafePutToPort((struct Message *)ts_msg,"TinyMeter"))
  2461.     {
  2462.         WaitPort(p_reply);
  2463.         return(GetMsg(p_reply));
  2464.     }
  2465.     }
  2466.     return(0L);
  2467. }
  2468.  
  2469. ///
  2470. /******************************************/
  2471. /* snapWindow method                      */
  2472. /******************************************/
  2473. ///
  2474. snapWindow(struct IClass *cl,Object *obj, struct Msg *msg)
  2475. {
  2476.     struct TestMessage *testMsg;
  2477.  
  2478.     testMsg=TestSettings(test_getwin);
  2479.  
  2480.     set(IN_posx,    MUIA_String_Integer     ,testMsg->posx);
  2481.     set(IN_posy,    MUIA_String_Integer     ,testMsg->posy);
  2482.     set(IN_sizx,    MUIA_String_Integer     ,testMsg->sizx);
  2483. }
  2484. ///
  2485. /******************************************/
  2486. /* save settings and the method for it    */
  2487. /******************************************/
  2488. ///
  2489. #define save_save      0
  2490. #define save_use       1
  2491. #define save_test      2
  2492. #define save_file      3
  2493. #define save_cancel    4
  2494.  
  2495. struct SaveSetMsg
  2496. {
  2497.     ULONG           MethodID;
  2498.     ULONG           what;
  2499. };
  2500.  
  2501. getSettings(struct tm_sys_set *set)
  2502. {
  2503.     ULONG   dummy;
  2504.     struct  ls_layout *src;
  2505.  
  2506.     get(NB_col  ,MUIA_Numeric_Value,&dummy);set->colums         =(UWORD)dummy;
  2507.     get(NB_bordx,MUIA_Numeric_Value,&dummy);set->win_border_x   =(UWORD)dummy;
  2508.     get(NB_bordy,MUIA_Numeric_Value,&dummy);set->win_border_y   =(UWORD)dummy;
  2509.     get(NB_spcx ,MUIA_Numeric_Value,&dummy);set->win_space_x    =(UWORD)dummy;
  2510.     get(NB_spcy ,MUIA_Numeric_Value,&dummy);set->win_space_y    =(UWORD)dummy;
  2511.     get(NB_wait ,MUIA_Numeric_Value,&dummy);set->start_wait     =(UWORD)dummy;
  2512.     get(NB_mem  ,MUIA_Numeric_Value,&dummy);set->mem_refresh    =(UWORD)dummy;
  2513.     get(NB_vol  ,MUIA_Numeric_Value,&dummy);set->vol_refresh    =(UWORD)dummy;
  2514.     get(NB_pri  ,MUIA_Numeric_Value,&dummy);set->pri            =(BYTE) dummy;
  2515.     get(CM_Falling,MUIA_Selected,   &dummy);set->lay_falling    =(UBYTE)dummy;
  2516.  
  2517.     DoMethod(ls_Switch,MUIM_List_GetEntry,1,&src); set->bg_type              =src->entry_selected;
  2518.     DoMethod(ls_Switch,MUIM_List_GetEntry,2,&src); set->win_backfront        =src->entry_selected;
  2519.     DoMethod(ls_Switch,MUIM_List_GetEntry,3,&src); set->win_move             =src->entry_selected;
  2520.     DoMethod(ls_Switch,MUIM_List_GetEntry,4,&src); set->bd_type              =src->entry_selected;
  2521.     DoMethod(ls_Switch,MUIM_List_GetEntry,6,&src); set->start_usescreennotify=src->entry_selected;
  2522.     DoMethod(ls_Switch,MUIM_List_GetEntry,7,&src); set->Executive            =src->entry_selected;
  2523.  
  2524.     getColor(&set->bg_color,    MN_Colors[0]);
  2525.     getColor(&set->bright_color,MN_Colors[1]);
  2526.     getColor(&set->dark_color,  MN_Colors[2]);
  2527.  
  2528.     get(ST_PubScr ,MUIA_String_Contents,&dummy); strcpy(&set->pub_name[0]   ,(char *)dummy);
  2529.     get(ST_bg     ,MUIA_String_Contents,&dummy); strcpy(&set->bg_picture[0] ,(char *)dummy);
  2530.     get(IN_sizx   ,MUIA_String_Integer, &dummy); set->x_siz=(UWORD)dummy;
  2531.     get(IN_posx   ,MUIA_String_Integer, &dummy); set->x_pos=(UWORD)dummy;
  2532.     get(IN_posy   ,MUIA_String_Integer, &dummy); set->y_pos=(UWORD)dummy;
  2533. }
  2534.  
  2535. static saveSettings(Object *listv, struct tm_sys_set *set, char *file)
  2536. {
  2537.     int                 i;
  2538.     ULONG               my_file;
  2539.     struct tm_gau_set   *act;
  2540.  
  2541.     if(my_file=(ULONG)Open(file,MODE_NEWFILE))
  2542.     {
  2543.     Write(my_file,set,(ULONG)sizeof(struct tm_sys_set));
  2544.     for (i=0;;i++)
  2545.     {
  2546.         DoMethod(listv,MUIM_List_GetEntry,i,&act);
  2547.         if(!act)  break;
  2548.         if(i==63) break;
  2549.         Write(my_file,act,(ULONG)sizeof(struct tm_gau_set));
  2550.     }
  2551.     Close(my_file);
  2552.     }
  2553. }
  2554.  
  2555. ULONG saveManager(struct IClass *cl,Object *obj, struct SaveSetMsg *msg)
  2556. {
  2557.     int i=0;
  2558.     char *file;
  2559.  
  2560.     getSettings(maindata->set);
  2561.     switch (msg->what)
  2562.     {
  2563.     case    save_save:
  2564.         saveSettings(visible,maindata->set,"ENVARC:TinyMeter");
  2565.     case    save_use:
  2566.         saveSettings(visible,maindata->set,"ENV:TinyMeter");
  2567.         TestSettings(test_test);
  2568.         while(pubscr[i]) FreeVec(pubscr[i++]);
  2569.         DoMethod((Object *)xget(obj,MUIA_ApplicationObject),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  2570.         return(0L);
  2571.     case    save_test:
  2572.         TestSettings(test_test);
  2573.         return(obj);
  2574.     case    save_file:
  2575.         if(file=getfilename(obj,GetStr(MM_SaveTitle),"#?.tm",TRUE))
  2576.             saveSettings(visible,maindata->set,file);
  2577.         break;
  2578.     case    save_cancel:
  2579.         loadSettings(obj,maindata,"ENV:TinyMeter");
  2580.         insertSettings(maindata->set,maindata->list);
  2581.         TestSettings(test_test);
  2582.         DoMethod((Object *)xget(obj,MUIA_ApplicationObject),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  2583.         break;
  2584.     }
  2585.     return((ULONG)DoSuperMethodA(cl,obj,msg));
  2586. }
  2587. ///
  2588. /******************************************/
  2589. /* other MainWindow methods               */
  2590. /******************************************/
  2591. ///
  2592. struct DoubleClkMsg
  2593. {
  2594.     ULONG   MethodID;
  2595.     struct  MainData *data;
  2596. };
  2597.  
  2598. static ULONG Dis_DoubleClick2(struct IClass *cl,Object *obj, struct DoubleClkMsg *msg)
  2599. {
  2600.     struct ls_layout *src;
  2601.  
  2602.     DoMethod(ls_Switch,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&src);
  2603.     if(src)
  2604.     {
  2605.     if(src->entry_max>0)
  2606.     {
  2607.         src->entry_selected++;if(src->entry_max<src->entry_selected)src->entry_selected=0;
  2608.         DoMethod(ls_Switch,MUIM_List_Redraw,MUIV_List_Redraw_Active);
  2609.     }
  2610.     return(DoSuperMethodA(cl,obj,msg));
  2611.     }
  2612.     else return(0L);
  2613. }
  2614.  
  2615. static ULONG Dis_DoubleClick1(struct IClass *cl,Object *obj, struct DoubleClkMsg *msg)
  2616. {
  2617.     char   *my_ptr;
  2618.  
  2619.     DoMethod(ls_PubScr,MUIM_List_GetEntry,MUIV_List_GetEntry_Active,&my_ptr);
  2620.     if(my_ptr)
  2621.     {
  2622.     set(ST_PubScr,MUIA_String_Contents,my_ptr);
  2623.     DoMethod(PO_PubScr,MUIM_Popstring_Close,0L);
  2624.     return(DoSuperMethodA(cl,obj,msg));
  2625.     }
  2626.     else return(0L);
  2627. }
  2628.  
  2629. ULONG MainWindow_Finish(struct IClass *cl,Object *obj,Msg *msg)
  2630. {
  2631.     int i=0;
  2632.  
  2633.     struct MainData *data;
  2634.     data=INST_DATA(cl,obj);
  2635.     while(pubscr[i++]) FreeVec(pubscr[i]); pubscr[i]=0;
  2636.     DoMethod((Object *)xget(obj,MUIA_ApplicationObject),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  2637.     return((ULONG)0L);
  2638. }
  2639.  
  2640. static GetPubScreens()
  2641. {
  2642.     struct List     *PubScreenList;
  2643.     struct PubScreenNode *ScreenNode;
  2644.     int i=0;
  2645.     PubScreenList = LockPubScreenList();
  2646.     for(ScreenNode=(struct PubScreenNode *)PubScreenList->lh_Head;ScreenNode->psn_Node.ln_Succ;ScreenNode=(struct PubScreenNode *)ScreenNode->psn_Node.ln_Succ)
  2647.     {
  2648.     pubscr[i]=(char *)AllocVec(256L,0L);
  2649.     strcpy(pubscr[i],ScreenNode->psn_Node.ln_Name);
  2650.     i++;
  2651.     }
  2652.     UnlockPubScreenList();
  2653. }
  2654.  
  2655. static ULONG MainWindow_New(struct IClass *cl,Object *obj,Msg *msg)
  2656. {
  2657.     struct MainData *data;
  2658.     int    i;
  2659.     GetPubScreens();
  2660.     if (obj = (Object *)
  2661.     DoSuperNew(cl,obj,
  2662.         MUIA_Window_Title, GetStr(MO_Title),
  2663.         MUIA_Window_ID   , MAKE_ID('T','I','N','Y'),
  2664.         WindowContents, VGroup, ButtonFrame,
  2665.         Child, HGroup,
  2666.             Child, VGroup, MUIA_Background, MUII_SHADOW,
  2667.             Child, HVSpace,
  2668.             Child, BodychunkObject,
  2669.                 MUIA_FixWidth             , LOGO_WIDTH ,
  2670.                 MUIA_FixHeight            , LOGO_HEIGHT,
  2671.                 MUIA_Bitmap_Width         , LOGO_WIDTH ,
  2672.                 MUIA_Bitmap_Height        , LOGO_HEIGHT,
  2673.                 MUIA_Bodychunk_Depth      , LOGO_DEPTH ,
  2674.                 MUIA_Bodychunk_Body       , (UBYTE *)logo_body,
  2675.                 MUIA_Bodychunk_Compression, LOGO_COMPRESSION,
  2676.                 MUIA_Bodychunk_Masking    , LOGO_MASKING,
  2677.                 MUIA_Bitmap_SourceColors  , (ULONG *)logo_colors,
  2678.                 MUIA_Bitmap_Transparent   , 0,
  2679.                 MUIA_ShortHelp, "Greets to: hANGKOK, pEPE, bEZZZERK, tRACER, rALPH...",
  2680.             End,
  2681.             End,
  2682.             Child, RegisterGroup(mainlister),
  2683.             MUIA_Register_Frame, TRUE,
  2684.             Child, HGroup,
  2685.                 Child, RegisterGroup(sublister),
  2686.                 MUIA_Register_Frame, TRUE,
  2687.                 Child, HGroup,
  2688.                     Child, ColGroup(2), GroupFrameT(GetStr(MOL_Handler)),
  2689.                     Child, HVSpace,
  2690.                     Child, HVSpace,
  2691.                     Child, Label(GetStr(MO_MemRefresh)),
  2692.                     Child, ColGroup(2), Child, NB_mem=MUI_MakeObject(MUIO_NumericButton,NULL,1,100,GetStr(MO_fmt_seconds)), Child, HVSpace, End,
  2693.                     Child, Label(GetStr(MO_VolRefresh)),
  2694.                     Child, ColGroup(2), Child, NB_vol=MUI_MakeObject(MUIO_NumericButton,NULL,1,100,GetStr(MO_fmt_seconds)), Child, HVSpace, End,
  2695.                     Child, Label(GetStr(MO_Wait)),
  2696.                     Child, ColGroup(2), Child, NB_wait=MUI_MakeObject(MUIO_NumericButton,NULL,0,100,GetStr(MO_fmt_seconds)), Child, HVSpace, End,
  2697.                     Child, Label(GetStr(MO_TaskPrio)),
  2698.                     Child, ColGroup(2), Child, NB_pri=MUI_MakeObject(MUIO_NumericButton,NULL,-128,127,"%ld"), Child, HVSpace, End,
  2699.                     Child, HVSpace,
  2700.                     Child, HVSpace,
  2701.                     End,
  2702.                     Child, ColGroup(2), GroupFrameT(GetStr(MOL_sub_Layout)),
  2703.                     Child, HVSpace,
  2704.                     Child, HVSpace,
  2705.                     Child, Label(GetStr(MO_Colums)),
  2706.                     Child, ColGroup(2), Child, NB_col=MUI_MakeObject(MUIO_NumericButton,NULL,1,32,"%3ld"), Child, HVSpace, End,
  2707.                     Child, Label(GetStr(MO_FallingCol)),
  2708.                     Child, HGroup, Child, CM_Falling=CheckMark(NULL), Child, HVSpace, End,
  2709.                     Child, Label(GetStr(MO_SpaceX)),
  2710.                     Child, ColGroup(2), Child, NB_spcx=MUI_MakeObject(MUIO_NumericButton,NULL,0,256,GetStr(MO_fmt_pixels)), Child, HVSpace, End,
  2711.                     Child, Label(GetStr(MO_SpaceY)),
  2712.                     Child, ColGroup(2), Child, NB_spcy=MUI_MakeObject(MUIO_NumericButton,NULL,0,256,GetStr(MO_fmt_pixels)), Child, HVSpace, End,
  2713.                     Child, Label(GetStr(MO_BordX)),
  2714.                     Child, ColGroup(2), Child, NB_bordx=MUI_MakeObject(MUIO_NumericButton,NULL,0,256,GetStr(MO_fmt_pixels)), Child, HVSpace, End,
  2715.                     Child, Label(GetStr(MO_BordY)),
  2716.                     Child, ColGroup(2), Child, NB_bordy=MUI_MakeObject(MUIO_NumericButton,NULL,0,256,GetStr(MO_fmt_pixels)), Child, HVSpace, End,
  2717.                     Child, HVSpace,
  2718.                     Child, HVSpace,
  2719.                     End,
  2720.                 End,
  2721.                 Child, lv_Switch=(Object *)ListviewObject,
  2722.                     MUIA_Listview_Input, TRUE,
  2723.                     MUIA_Listview_DoubleClick, TRUE,
  2724.                     MUIA_Listview_List, ls_Switch=(Object *)ListObject,
  2725.                     MUIA_Frame, MUIV_Frame_InputList,
  2726.                     MUIA_List_ConstructHook, &lay_ConstructHook,
  2727.                     MUIA_List_DestructHook , &lay_DestructHook,
  2728.                     MUIA_List_DisplayHook  , &lay_DisplayHook,
  2729.                     MUIA_List_Format       , "MIW=5 MAW=100 BAR,",
  2730.                     MUIA_List_Active, MUIV_List_Active_Top,
  2731.                     End,
  2732.                 End,
  2733.                 Child, ColGroup(2),
  2734.                     Child, HVSpace,
  2735.                     Child, HVSpace,
  2736.                     Child, Label(GetStr(MO_Public)),
  2737.                     Child, PO_PubScr=(Object *)PopobjectObject,
  2738.                     MUIA_Popstring_String, ST_PubScr=(Object *)String(NULL,80),
  2739.                     MUIA_Popstring_Button, PopButton(MUII_PopUp),
  2740.                     MUIA_Popobject_Object, lv_PubScr=(Object *)ListviewObject,
  2741.                         MUIA_Listview_Input, TRUE,
  2742.                         MUIA_Listview_DoubleClick, TRUE,
  2743.                         MUIA_Listview_List, ls_PubScr=(Object *)ListObject,
  2744.                         MUIA_Frame, MUIV_Frame_InputList,
  2745.                         MUIA_List_Active, MUIV_List_Active_Top,
  2746.                         MUIA_List_SourceArray,&pubscr[0],
  2747.                         End,
  2748.                     End,
  2749.                     End,
  2750.                     Child, Label(GetStr(MO_WindowPos)),
  2751.                     Child, ColGroup(2),
  2752.                     Child, IN_posx=StringObject,
  2753.                         StringFrame,
  2754.                         MUIA_String_Accept , "0123456879",
  2755.                     End,
  2756.                     Child, IN_posy=StringObject,
  2757.                         StringFrame,
  2758.                         MUIA_String_Accept , "0123456879",
  2759.                     End,
  2760.                     End,
  2761.                     Child, Label(GetStr(MO_WindowSiz)),
  2762.                     Child, ColGroup(2),
  2763.                     MUIA_Group_SameWidth, TRUE,
  2764.                     Child, IN_sizx=StringObject,
  2765.                         StringFrame,
  2766.                         MUIA_String_Accept , "0123456879",
  2767.                     End,
  2768.                     Child, BT_Snap=SimpleButton(GetStr(MO_Snap)),
  2769.                     End,
  2770.                     Child, Label(GetStr(MO_BackgroundPic)),
  2771.                     Child, ST_bg=PopaslObject,
  2772.                     MUIA_Popstring_String, String(NULL,80),
  2773.                     MUIA_Popstring_Button, PopButton(MUII_PopFile),
  2774.                     ASLFO_TitleText  , GetStr(MO_SelectBg),
  2775.                     End,
  2776.                     Child, Label(GetStr(MO_BackgroundCol)),
  2777.                     Child, ColGroup(2),Child, MN_Colors[0]=MakePen(), Child, HVSpace, End,
  2778.                     Child, Label(GetStr(MO_BrightCol)),
  2779.                     Child, ColGroup(2),Child, MN_Colors[1]=MakePen(), Child, HVSpace, End,
  2780.                     Child, Label(GetStr(MO_DarkCol)),
  2781.                     Child, ColGroup(2),Child, MN_Colors[2]=MakePen(), Child, HVSpace, End,
  2782.                     Child, HVSpace,
  2783.                     Child, HVSpace,
  2784.                 End,
  2785.                 End,
  2786.             End,
  2787.             Child, VGroup,
  2788.                 Child, NewObject(CL_ChooseFields->mcc_Class,NULL,TAG_DONE),
  2789.             End,
  2790.             End,
  2791.         End,
  2792.         Child, HGroup,
  2793.             Child, BT_Save = (Object *)SimpleButton(GetStr(MO_Save)),
  2794.             Child, BT_Use = (Object *)SimpleButton(GetStr(MO_Use)),
  2795.             Child, BT_Test = (Object *)SimpleButton(GetStr(MO_Test)),
  2796.             Child, BT_Cancel = (Object *)SimpleButton(GetStr(MO_Cancel)),
  2797.         End,
  2798.         End,
  2799.     End)
  2800.     {
  2801.     data=INST_DATA(cl,obj);
  2802.     set(BT_Save     ,MUIA_ShortHelp,GetStr(MH_Save));
  2803.     set(BT_Use      ,MUIA_ShortHelp,GetStr(MH_Use));
  2804.     set(BT_Test     ,MUIA_ShortHelp,GetStr(MH_Test));
  2805.     set(BT_Cancel   ,MUIA_ShortHelp,GetStr(MH_Cancel));
  2806.     set(NB_mem      ,MUIA_ShortHelp,GetStr(MH_MemRefresh));
  2807.     set(NB_vol      ,MUIA_ShortHelp,GetStr(MH_VolRefresh));
  2808.     set(NB_wait     ,MUIA_ShortHelp,GetStr(MH_Wait));
  2809.     set(lv_Switch   ,MUIA_ShortHelp,GetStr(MH_Flags));
  2810.     set(PO_PubScr   ,MUIA_ShortHelp,GetStr(MH_Public));
  2811.     set(IN_posx     ,MUIA_ShortHelp,GetStr(MH_PosX));
  2812.     set(IN_posy     ,MUIA_ShortHelp,GetStr(MH_PosY));
  2813.     set(IN_sizx     ,MUIA_ShortHelp,GetStr(MH_SizX));
  2814.     set(BT_Snap     ,MUIA_ShortHelp,GetStr(MH_Snap));
  2815.     set(ST_bg       ,MUIA_ShortHelp,GetStr(MH_BackgroundPic));
  2816.     set(MN_Colors[0],MUIA_ShortHelp,GetStr(MH_BackgroundCol));
  2817.     set(MN_Colors[1],MUIA_ShortHelp,GetStr(MH_BrightCol));
  2818.     set(MN_Colors[2],MUIA_ShortHelp,GetStr(MH_DarkCol));
  2819.     set(NB_col      ,MUIA_ShortHelp,GetStr(MH_Colums));
  2820.     set(NB_spcx     ,MUIA_ShortHelp,GetStr(MH_SpaceX));
  2821.     set(NB_spcy     ,MUIA_ShortHelp,GetStr(MH_SpaceX));
  2822.     set(NB_bordx    ,MUIA_ShortHelp,GetStr(MH_BordX));
  2823.     set(NB_bordy    ,MUIA_ShortHelp,GetStr(MH_BordY));
  2824.     DoMethod(BT_Snap  ,MUIM_Notify,MUIA_Pressed                ,FALSE   ,obj,1,Dis_ID_Snap);
  2825.     DoMethod(BT_Save  ,MUIM_Notify,MUIA_Pressed                ,FALSE   ,obj,2,Dis_ID_Save,save_save);
  2826.     DoMethod(BT_Use   ,MUIM_Notify,MUIA_Pressed                ,FALSE   ,obj,2,Dis_ID_Save,save_use );
  2827.     DoMethod(BT_Test  ,MUIM_Notify,MUIA_Pressed                ,FALSE   ,obj,2,Dis_ID_Save,save_test);
  2828.     DoMethod(lv_PubScr,MUIM_Notify,MUIA_Listview_DoubleClick   ,TRUE    ,obj,2,Dis_ID_DoubleClick1,data);
  2829.     DoMethod(lv_Switch,MUIM_Notify,MUIA_Listview_DoubleClick   ,TRUE    ,obj,1,Dis_ID_DoubleClick2);
  2830.     DoMethod(obj      ,MUIM_Notify,MUIA_Window_MenuAction      ,MEN_SAVE,obj,2,Dis_ID_Save,save_file);
  2831.     DoMethod(obj      ,MUIM_Notify,MUIA_Window_MenuAction      ,MEN_OPEN,obj,2,Dis_ID_Load,load_file);
  2832.     DoMethod(BT_Cancel,MUIM_Notify,MUIA_Pressed                ,FALSE   ,obj,2,Dis_ID_Save,save_cancel);
  2833.     for(i=0;i<8;i++)DoMethod(ls_Switch,MUIM_List_InsertSingle,&switches[i],MUIV_List_Insert_Bottom);
  2834.     DoMethod(obj      ,Dis_ID_Load,load_standard);
  2835.     }
  2836.     return((ULONG)obj);
  2837. }
  2838. ///
  2839.  
  2840. static __saveds __asm ULONG MainWindowDispatcher(__a0 struct IClass *cl,__a2 Object *obj,__a1 Msg msg)
  2841. {
  2842.     switch (msg->MethodID)
  2843.     {
  2844.         case OM_NEW              : return (MainWindow_New    (cl,obj,(APTR)msg));
  2845.         case Dis_ID_Finish       : return (MainWindow_Finish (cl,obj,(APTR)msg));
  2846.         case Dis_ID_DoubleClick1 : return (Dis_DoubleClick1  (cl,obj,(APTR)msg));
  2847.         case Dis_ID_DoubleClick2 : return (Dis_DoubleClick2  (cl,obj,(APTR)msg));
  2848.         case Dis_ID_Save         : return (saveManager       (cl,obj,(APTR)msg));
  2849.         case Dis_ID_Snap         : return (snapWindow        (cl,obj,(APTR)msg));
  2850.         case Dis_ID_Load         : return (loadManager       (cl,obj,(APTR)msg));
  2851.     }
  2852.     return (DoSuperMethodA    (cl,obj,(APTR)msg));
  2853. }
  2854.  
  2855. /*************************************************/
  2856. /* Init all classes                              */
  2857. /*************************************************/
  2858. ///
  2859. VOID ExitClasses(VOID)
  2860. {
  2861.     if (CL_FieldsList  ) MUI_DeleteCustomClass(CL_FieldsList);
  2862.     if (CL_ChooseFields) MUI_DeleteCustomClass(CL_ChooseFields);
  2863.     if (CL_MainWindow)   MUI_DeleteCustomClass(CL_MainWindow);
  2864.     if (CL_Composer)     MUI_DeleteCustomClass(CL_Composer);
  2865.     if (CL_Launcher)     MUI_DeleteCustomClass(CL_Launcher);
  2866. }
  2867.  
  2868. BOOL InitClasses(VOID)
  2869. {
  2870.     CL_MainWindow    = MUI_CreateCustomClass(NULL,MUIC_Window   ,NULL, sizeof(struct MainData)           ,MainWindowDispatcher);
  2871.     CL_FieldsList    = MUI_CreateCustomClass(NULL,MUIC_List     ,NULL, sizeof(struct FieldsList_Data)    ,FieldsList_Dispatcher);
  2872.     CL_ChooseFields  = MUI_CreateCustomClass(NULL,MUIC_Group    ,NULL, sizeof(struct ChooseFields_Data)  ,ChooseFields_Dispatcher);
  2873.     CL_Composer      = MUI_CreateCustomClass(NULL,MUIC_Window   ,NULL, sizeof(struct Composer_Data)      ,ComposerDispatcher);
  2874.     CL_Launcher      = MUI_CreateCustomClass(NULL,MUIC_Window   ,NULL, sizeof(struct Launcher_Data)      ,LauncherDispatcher);
  2875.     if ( CL_FieldsList && CL_ChooseFields && CL_MainWindow && CL_Composer && CL_Launcher ) return(TRUE);
  2876.     ExitClasses();
  2877.     return(FALSE);
  2878. }
  2879. ///
  2880. /*************************************************/
  2881. /* Main: MUIApplication and Aboutwindow          */
  2882. /*************************************************/
  2883. ///
  2884.  
  2885. #include <exec/tasks.h>
  2886.  
  2887. #ifdef _DCC
  2888.  
  2889. int brkfunc(void) { return(0); }
  2890.  
  2891. #endif
  2892.  
  2893. void LocalizeSwitches(struct ls_layout *ll)
  2894. {
  2895.     int i;
  2896.     for (;ll->entry_desc!=NULL;ll++)
  2897.     {
  2898.     ll->entry_desc=GetStr((int)ll->entry_desc);
  2899.     for(i=0;i<6;i++)
  2900.     {
  2901.         if (ll->entry[i]!=NULL) ll->entry[i]=GetStr((int)ll->entry[i]);
  2902.         else ll->entry[i]=" ";
  2903.     }
  2904.     }
  2905. }
  2906.  
  2907. int main(int argc, char *argv[])
  2908. {
  2909.     Object          *app,
  2910.             *window;
  2911.     struct  Task    *me;
  2912.  
  2913.     if (MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN))
  2914.     {
  2915.     if(me=FindTask(NULL))
  2916.     {
  2917.         if((me->tc_SPUpper-me->tc_SPLower)>8000)
  2918.         {
  2919.         if(maindata=(struct tm_data *)AllocVec(sizeof(struct tm_data),MEMF_CLEAR))
  2920.         {
  2921.             if(InitTestSettings())
  2922.             {
  2923.             InitClasses();
  2924.             InitLocale();
  2925.             LocalizeNewMenu(MenuData1);
  2926.             LocalizeNewMenu(CmpMenuData);
  2927.             LocalizeNewMenu(LauMenuData);
  2928.             LocalizeSwitches(switches);
  2929.             LocalizeStringArray(gau_types);
  2930.             LocalizeStringArray(types);
  2931.             LocalizeStringArray(indent);
  2932.             LocalizeStringArray(mainlister);
  2933.             LocalizeStringArray(sublister);
  2934.             LocalizeStringArray(regcomposer);
  2935.             LocalizeStringArray(reglauncher);
  2936.             LocalizeStringArray(cyplace);
  2937.             LocalizeStringArray(cyindent);
  2938.             strcpy(&default_gauge.label[0],GetStr(MDef_Label));
  2939.             strcpy(&default_gauge.format[0],GetStr(MDef_fmt));
  2940.             strcpy(&default_gauge.expansion[0],GetStr(MDef_Device));
  2941.  
  2942.             app = ApplicationObject,
  2943.                 MUIA_Application_Title      ,   "TinyMeterPrefs V4.20",
  2944.                 MUIA_Application_Version    ,   "$VER: TinyMeterPrefs V4.20 (14.5.96)",
  2945.                 MUIA_Application_Copyright  ,   "©1994-96, Tinic Urou",
  2946.                 MUIA_Application_Author     ,   "Tinic Urou",
  2947.                 MUIA_Application_Description,   GetStr(MA_Description),
  2948.                 MUIA_Application_Base       ,   "TMPREFS",
  2949.                 MUIA_Application_HelpFile   ,   "HELP:TinyMeter.guide",
  2950.                 MUIA_Application_Menustrip  ,   MN_Main = MUI_MakeObject(MUIO_MenustripNM,MenuData1,0),
  2951.                 SubWindow                   ,   window = (Object *)NewObject(CL_MainWindow->mcc_Class,NULL,TAG_DONE),
  2952.                 SubWindow                   ,   WI_About = WindowObject,
  2953.                                     MUIA_Window_Title, GetStr(MA_About_Title),
  2954.                                     MUIA_Window_ID   , MAKE_ID('T','M','A','B'),
  2955.                                     WindowContents, VGroup, ButtonFrame,
  2956.                                     Child, BodychunkObject,
  2957.                                         MUIA_FixWidth             , ABOUT_WIDTH ,
  2958.                                         MUIA_FixHeight            , ABOUT_HEIGHT,
  2959.                                         MUIA_Bitmap_Width         , ABOUT_WIDTH ,
  2960.                                         MUIA_Bitmap_Height        , ABOUT_HEIGHT,
  2961.                                         MUIA_Bodychunk_Depth      , ABOUT_DEPTH ,
  2962.                                         MUIA_Bodychunk_Body       , (UBYTE *)about_body,
  2963.                                         MUIA_Bodychunk_Compression, ABOUT_COMPRESSION,
  2964.                                         MUIA_Bodychunk_Masking    , ABOUT_MASKING,
  2965.                                         MUIA_Bitmap_SourceColors  , (ULONG *)about_colors,
  2966.                                         MUIA_Bitmap_Transparent   , 0,
  2967.                                     End,
  2968.                                     End,
  2969.                                 End,
  2970.                 SubWindow                   ,   WI_HelpFmt = WindowObject,
  2971.                                     MUIA_Window_Title, GetStr(MH_FormatHelp),
  2972.                                     MUIA_Window_ID  , MAKE_ID('T','H','L','P'),
  2973.                                     MUIA_Window_UseRightBorderScroller, TRUE,
  2974.                                     MUIA_Window_UseBottomBorderScroller, TRUE,
  2975.                                     WindowContents, VGroup,
  2976.                                     Child, ScrollgroupObject,
  2977.                                         MUIA_Scrollgroup_UseWinBorder, TRUE,
  2978.                                         MUIA_Scrollgroup_Contents, VirtgroupObject,TextFrame,
  2979.                                         Child, TextObject,
  2980.                                             MUIA_Text_Contents, GetStr(MOH_Format),
  2981.                                         End,
  2982.                                         End,
  2983.                                     End,
  2984.                                     End,
  2985.                                 End,
  2986.                 SubWindow                   ,   WI_HelpClock = WindowObject,
  2987.                                     MUIA_Window_Title, GetStr(MH_ClockHelp),
  2988.                                     MUIA_Window_ID  , MAKE_ID('T','H','L','P'),
  2989.                                     MUIA_Window_UseRightBorderScroller, TRUE,
  2990.                                     MUIA_Window_UseBottomBorderScroller, TRUE,
  2991.                                     WindowContents, VGroup,
  2992.                                     Child, ScrollgroupObject,
  2993.                                         MUIA_Scrollgroup_UseWinBorder, TRUE,
  2994.                                         MUIA_Scrollgroup_Contents, VirtgroupObject,TextFrame,
  2995.                                         Child, TextObject,
  2996.                                             MUIA_Text_Contents, GetStr(MOH_Clock),
  2997.                                         End,
  2998.                                         End,
  2999.                                     End,
  3000.                                     End,
  3001.                                 End,
  3002.                   End;
  3003.  
  3004.             if(app)
  3005.             {
  3006.                 DoMethod(app         ,MUIM_Notify,MUIA_Application_MenuAction,MEN_QUIT ,app     ,    2,MUIM_Application_ReturnID ,MUIV_Application_ReturnID_Quit);
  3007.                 DoMethod(app         ,MUIM_Notify,MUIA_Application_MenuAction,MEN_ABOUT,WI_About,    3,MUIM_Set                  ,MUIA_Window_Open,TRUE);
  3008.                 DoMethod(WI_About    ,MUIM_Notify,MUIA_Window_CloseRequest   ,TRUE     ,WI_About,    3,MUIM_Set                  ,MUIA_Window_Open,FALSE);
  3009.                 DoMethod(WI_HelpFmt  ,MUIM_Notify,MUIA_Window_CloseRequest   ,TRUE     ,WI_HelpFmt,  3,MUIM_Set                  ,MUIA_Window_Open,FALSE);
  3010.                 DoMethod(WI_HelpClock,MUIM_Notify,MUIA_Window_CloseRequest   ,TRUE     ,WI_HelpClock,3,MUIM_Set                  ,MUIA_Window_Open,FALSE);
  3011.                 DoMethod(window,      MUIM_Notify,MUIA_Window_CloseRequest   ,TRUE     ,app,         2,MUIM_Application_ReturnID ,MUIV_Application_ReturnID_Quit);
  3012.                 set(window,MUIA_Window_Open,TRUE);
  3013.                 {
  3014.                 ULONG sigs = 0;
  3015.                 while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  3016.                 {
  3017.                     if (sigs)
  3018.                     {
  3019.                         sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  3020.                         if (sigs & SIGBREAKF_CTRL_C) break;
  3021.                     }
  3022.                 }
  3023.                 }                   
  3024.                 MUI_DisposeObject(app);
  3025.             }
  3026.             ExitLocale();
  3027.             ExitClasses();
  3028.             FreeTestSettings();
  3029.             }
  3030.             if(maindata->set)FreeVec(maindata->set);
  3031.             FreeVec(maindata);
  3032.         }
  3033.         }
  3034.         else MUI_RequestA(NULL,NULL,0,"Early Startup","OK","Stacksize too small!\n\nA minimum of 8192 bytes is needed.",NULL);
  3035.     }
  3036.     CloseLibrary(MUIMasterBase);
  3037.     }
  3038.     return(0);
  3039. }
  3040.  
  3041. int wbmain(struct WBStartup *wb_startup)
  3042. {
  3043.     return(main(0, (char **)wb_startup));
  3044. }
  3045.  
  3046. ///
  3047.